如何使用 Ajax.ActionLink? [英] How to use Ajax.ActionLink?
本文介绍了如何使用 Ajax.ActionLink?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
首先,asp.net mvc中Ajax.*
方法的文档在哪里?
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?
推荐答案
当然,非常类似问题 之前被问过.为 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屋!
查看全文