In MVC3, with WebViewP开发者_如何学Cages, there is the new property PageData which can be used to pass arguments to a parent layout page.
Unfortunately, we still have some legacy WebFormsView pages in our app and we want to have similar behavior, in being able to pass arguments to a parent master page. Is there a way to do this?
With MVC3 you can use the ViewBag
to make data available to the master page.
E.g.
In View:
@{
ViewBag.Title = "Home Page";
}
In Master Page:
<title>@ViewBag.Title</title>
Update:
Difference between PageData and ViewData
You can use the ViewBag
.
精彩评论