如何使用Ajax.ActionLink? [英] How to use Ajax.ActionLink?
问题描述
首先,在这里是阿贾克斯的文档。*
在asp.net mvc的方法呢?
First of all, where is the documentation for Ajax.*
methods in asp.net mvc?
能否 Ajax.ActionLink
用来调用一个动作,得到了局部视图,打开一个模态窗口,并把内容呢?
Can Ajax.ActionLink
be used to call an action, get a partial view, open a modal window and put the content in it?
推荐答案
当然,一个很<一个href=\"http://stackoverflow.com/questions/861235/asp-net-mvc-modal-dialog-popup-best-practice\">similar问题被问过。设置控制器Ajax请求:
Sure, a very similar question was asked before. Set the controller for ajax requests:
public ActionResult Show()
{
if (Request.IsAjaxRequest())
{
return PartialView("Your_partial_view", new Model());
}
else
{
return View();
}
}
设置跳转链接通缉:
Set the action link as wanted:
@Ajax.ActionLink("Show",
"Show",
null,
new AjaxOptions { HttpMethod = "GET",
InsertionMode = InsertionMode.Replace,
UpdateTargetId = "dialog_window_id",
OnComplete = "your_js_function();" })
请注意,我使用的Razor视图引擎,并且您的AjaxOptions可能会根据你想要的不同而不同。终于在一个模式窗口中显示它。该 jQuery UI的对话框的建议。
Note that I'm using Razor view engine, and that your AjaxOptions may vary depending on what you want. Finally display it on a modal window. The jQuery UI dialog is suggested.
这篇关于如何使用Ajax.ActionLink?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!