gpt4 book ai didi

ajax - asp.net mvc 部分 View @Ajax.ActionLink 不起作用

转载 作者:行者123 更新时间:2023-12-04 06:45:04 26 4
gpt4 key购买 nike

我有一个查看页面

我的查看页面

<div id="beReplaced">
@Ajax.ActionLink("please click on me to bring the partial view",
"PatrialViewToBeCalled",
new AjaxOptions()
{UpdateTargetId = "beReplaced",
InsertionMode = InsertionMode.InsertAfter,
HttpMethod="Get",
LoadingElementId = "prgress" })
</div>

我有一个 Controller
public PartialViewResult PatrialViewToBeCalled()
{
var customer = db.Customers.First();

return PartialView("PartialViewThatMustBeShow",customer);
}

但是当我点击生成的链接时,它会将我带到一个新页面而不是
将局部 View 替换或附加到 div 标签。

有什么问题?

最佳答案

可能是您错过了:

<script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.js")" type="text/javascript"></script>

在主 View 中。这告诉主 View 识别 ajax 助手。

关于ajax - asp.net mvc 部分 View @Ajax.ActionLink 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8778002/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com