asp.net mvc partialview @Ajax.ActionLink 不起作用
我有一个视图页面
我的视图页面
<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>
有一个控制器,
public PartialViewResult PatrialViewToBeCalled()
{
var customer = db.Customers.First();
return PartialView("PartialViewThatMustBeShow",customer);
}
但是当我单击生成的链接时,它会将我带到一个新页面,而不是 将部分视图替换或附加到 div 标签。
有什么问题吗?
I have a view page
my view page
<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>
i have a Controller
public PartialViewResult PatrialViewToBeCalled()
{
var customer = db.Customers.First();
return PartialView("PartialViewThatMustBeShow",customer);
}
but when i click on the generated link it brings me to a new page instead of
replacing or appending the partial view to the div tag.
What's the problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
如果您使用 ASP .NET MVC 4,请确保它
也位于 body 标记的末尾。
If you are working with ASP .NET MVC 4 make sure that
is in the end of the body tag as well.
我已经为此工作了太长时间,认为它不起作用。查看页面源也没有显示任何内容。
最终,当我在 Firebug 的控制台中看到成功的请求时,我发现它确实有效。它只是在屏幕外展示它。在 Firebug 的 HTML 选项卡中,我终于找到了输出,尽管它没有显示在页面源代码中。
I've just been working on it for too long, thinking it did not work. Viewing the page source didn't show anything either.
Eventually, I found out it actually did work when I saw the successful requests in the console of Firebug. It only was showing it off screen. In the HTML tab of Firebug I finally found the output, even though it does not show up in the page source.
可能是您错过了:
在主视图中。这告诉主视图识别 ajax 助手。
It could have been that you were missing the:
In the main view. This tells the main view to recognize the ajax helper.
我找到了解决方案。该问题是由于 unobtrusive-ajax.min.js 文件损坏造成的。
I found the solution. The problem was due to the corrupted unobtrusive-ajax.min.js file.
如果您已将 jQuery 加载到页面中,为什么不使用简单的 jquery get/load 方法来获取部分视图呢?
Javascript
If you have jQuery loaded into your page, why not use the simple jquery get / load method to get the partial view ?
Javascript