0

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

hutchonoid
  • 32,982
  • 15
  • 99
  • 104
Miguel Moura
  • 36,732
  • 85
  • 259
  • 481

1 Answers1

4

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"]
KevB
  • 3,570
  • 1
  • 26
  • 29