【发布时间】:2014-04-24 17:07:20
【问题描述】:
我有一个局部视图,它正在一个名为 _Layout.cshtml 的共享布局中呈现。
_Layout.cshtml
<h1>@Html.Action("Home", "TestView");</h1>
控制器:
[ChildActionOnly]
public ActionResult TestView()
{
var model = new TestViewModel();
model.Title = "Default Title";
return PartialView("/Views/Shared/_TestView.cshtml", model);
}
_TestView.cshtml
@model TestMVC.Models.TestViewModel
@Model.Title
到目前为止一切正常,但我想知道是否可以从不同的动作/控制器更新模型。
示例:localhost:8888/home/index,我想显示默认标题,即“默认标题”,但在某些操作/控制器例如 localhost:8888/home/contactus
我想显示一个不同的标题前。 “联系我们表格标题”。
这可能吗?
【问题讨论】:
标签: c# asp.net asp.net-mvc-4