【发布时间】:2015-05-25 09:34:49
【问题描述】:
我正在通过 html.action 在我的主视图页面上加载我的部分视图。
这是我的查看代码:
_SectionLayout.cshtml
<html>
<head>
.....
</head>
<body>
<div id="wrapper">
@Html.Action("RenderUpperSection", "UpperSection")//render partial view on load of this master page.
</div>
<div class="EditContent">
@using (Html.BeginForm("Edit", "Section", new RouteValueDictionary() { { "id", Model.SectionId } }))
{
@RenderBody()//problem occurs here because here i am loading again my view(SectionIndex.cshtml) with this _SectionLayout.cshtml page.
}
</div>
</body>
</html>
我的控制器:UpperSection
[ChildActionOnly]
public ActionResult RenderUpperSection()
{
return PartialView("_TopSection");
}
在 html.action 上的 html beginform 的渲染体中加载带有布局页面的视图页面时出错
控制器:部分
public ActionResult Edit(string id)
{
return View("SectionIndex");
}
SectionIndex.cshtml:
@{
Layout = _SectionLayout.cshtml
}
//Rest of my code.
现在当我点击我的编辑按钮时,这一行出现错误:
@Html.Action("RenderUpperSection", "UpperSection")//
在控制器“MyProject.Web.Controllers.UpperSectionController”**上找不到公共操作方法“RenderUpperSection”。”
但是当我的 _SectionLayout.cshtml 布局页面第一次加载时,这个 RenderUpperSection 正在成功调用并渲染我的部分视图,但是当我点击编辑方法和我的编辑方法返回 SectionIndex 这个视图与 _SectionLayout.cshtml 然后我在母版页上得到上述错误。
第一次加载我的母版页时调用相同的方法,但单击编辑方法时出现错误。
谁能告诉我这是什么问题???
【问题讨论】:
标签: c# asp.net-mvc asp.net-mvc-4 razor