I have the following on an ASP.NET MVC 5.0 master view:
@Html.Partial(MVC.Shared.Views._Base, new { MasterViewName = "core" });
Then on the master view I tried to get the value:
@model dynamic
@Model.MasterViewName;
But I get the error:
'object' does not contain a definition for 'MasterViewName'
What am I missing?
Thank you, Miguel
You can pass in additional information to the partial by adding data into the ViewDataDictionary
.
In your example, it would look something like:
@Html.Partial(MVC.Shared.Views._Base, new ViewDataDictionary(ViewData) {{"MasterViewName", "core"}});
You could then access the MasterViewName
data from the page using:
ViewData["MasterViewName"]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.