我正在尝试用部分视图替换主视图中 div 的内容,具体取决于单击了哪个@Ajax.ActionLink。
最初我加载 _CaseLoad 局部视图,然后当我单击相关的 ActionLink 时,我希望能够在两个局部视图 _CaseLoad 和 _Vacancies 之间切换。我在“主”文件夹中有部分视图和索引视图。
当我单击“空缺”链接时,它会简要显示 LoadingElementID,但它不会用 _Vacancies 部分视图替换 _CaseLoad 部分视图?
控制器动作(MainController):
public ActionResult Index(int page = 1, string searchTerm = null)
{
MainIndexViewModel model = new MainIndexViewModel()
// Populate Model
return View(model);
}
主索引视图:
@model Project.WebUI.Models.MainIndexViewModel
@{
ViewBag.Title = "Index";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<div id="MainIndex">
<div id="Menu">
@Ajax.ActionLink("CaseLoad", "_CaseLoad", "Main", null, new AjaxOptions() { UpdateTargetId = "Main", InsertionMode = InsertionMode.Replace, HttpMethod = "GET",
LoadingElementId = "busycycle" }) |
@Ajax.ActionLink("Vacancies", "_Vacancies", "Main", null, new AjaxOptions() { UpdateTargetId = "Main", InsertionMode = InsertionMode.Replace, HttpMethod = "GET",
LoadingElementId = "busycycle" })
</div><hr/>
<div id="busycycle" style="display:none;"><img src="~/Content/images/preloader-w8-cycle-black.gif" /></div>
<div id="Main">
@Html.Partial("_CaseLoad")
</div>
</div>