加载局部视图上点击主视图 [英] Load partial view in main view on click
问题描述
我想获得一个局部视图,当用户点击链接在我的当前视图来加载,但它会持续局部视图,而再上同样的观点。
I'm trying to get a partial view to load on my current view when the user clicks the link but it keeps loading the partial view rather then on the same view.
不知道我错过了什么。
主视图控制器
public PartialViewResult MonitorDetail(MonitorType mType)
{
return PartialView("MonitorDetail", mType);
}
主视图
<script src="~/Scripts/jquery-2.1.1.js"></script>
<script src="~/Scripts/jquery.unobtrusive-ajax.js"></script>
<p class="lbutton radius">
@Ajax.ActionLink("SQL Cluster Online ", "MonitorDetail", "NOCCon", MonitorType.AHSSQLCluster, new AjaxOptions() { UpdateTargetId = "monitorDetail" })
<span class="lbutton-addition @(Model.SQLClusterOnline ? "online" : "offline")">
@(Model.SQLClusterOnline ? "Online" : "Offline")
</span></p>
<div id="monitorDetail"></div>
管窥
@model PAL.Intranet.MonitorType
<div>
You choose @Model.ToString()
</div>
也不断告诉我M型为空但我MonitorType传递给它的ActionLink的,所以我说这是为空的,所以我可以试着找出第一个问题,然后在第二个工作。
Also keeps telling me mType is null but i'm passing it MonitorType in the ActionLink so I added it as nullable so I can try and figure out the first issue and then work on the second.
推荐答案
如果其只显示局部视图,其因为你不包括 Ajax.ActionLink
工作(和它只是执行正常重定向)。确保您有包括 jQuery的。{}版本的.js
和 jquery.unobtrusive-ajax.js
If its displaying only the partial view, its because you have not included the required files for Ajax.ActionLink
to work (and its just performing a normal redirect). Ensure you have included jquery.{version}.js
and jquery.unobtrusive-ajax.js
原因参数 M型
为空是因为你不及格的值。它应该是
The reason parameter mType
is null is because you are not passing a value. It should be
@Ajax.ActionLink("SQL Cluster Online ", "MonitorDetail", "NOCCon", new { mtype = MonitorType.AHSSQLCluster }, new AjaxOptions() ....)
这篇关于加载局部视图上点击主视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!