ASP.NET MVC Master Page: "'Model' is not a member of 'System.Web.UI.Page'" -


My view is an ado. The Net unit framework is strongly typed with the Boolean property showname for the class.

  and lieutenant;% @ page ... masterpagesfile = "~ / view / share / site.masters" inheritance = "system web. Will see multimedia (of Thing)"%> ...  

I want to do something like this on my master page ...

  & lt;% @ Master ... Inherits = "System .Web.Mvc.ViewMasterPage "%> ... & lt; Div id = "menu" runat = "server" view = "& lt;% = Me.Page.Model.ShowMenu%>" & Gt; & Lt; Asp: ContentPlaceHolder ID = "MenuContent" runat = "server" / & gt; & Lt; / Div & gt;  

However, I get this error:

'Model' is not a member of 'System.Web.UI.Page'

< / Blockquote>

How can I use a view model from my master page?


Update

Oh:

Can not create server tag & lt;% ...%>

It is to use ... then instead of it.

You can not do what you need to do, your master page view model sets, such as :

  Inheritance = "System.web.mvc viewerpage & lt; baseloadel & gt;"  

... where besomodal is the base square that you will use in each single view. Due to this restriction, it is very brittle and you may not want to do it.

In any case, then each single view should be a model type that comes from the besomodel.

Then you can do this in your master page:

  <% = Model.ShowMenu%>  

Another option is to use the ViewData dictionary and if the action has not set it, then there is a sensible default value.

  & lt;% if ((bool)) (viewdown ["showmenu"] false)) {%> ... Render menu here ... & lt;%}% & gt;  

It is very ugly, so you can choose to use an assistant instead:

   & nbsp;  

and in your assistant:

  public static class MyExtensions {public static buttons should be found in the Renderer Menu (seeMaster Page page) {Return (Boole) (Page ViewData ["Renderman"]]? False;}}  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -