I have a website that will contain 2 type of layout.
- With no columns
- With 2 columns
Header, footer and lots of other parts are the same for both, but inside the main content, there 2 separate layouts and I'd like to choose between 2 site masters. How would I go about accomplishing this?
I was thinking about making a main开发者_Go百科 site master and have the one with the 2 column inherit from that. If that is the correct method, what are the keywords to google for, or you are free to explain inheriting site masters here.
Thank you,
Master pages can inside a master page themselves just like any other view. Just specify the master's MasterPageFile directive as usual:
<%@ Master Language="C#" MasterPageFile="~/Views/Shared/App.Master"
Inherits="System.Web.Mvc.ViewMasterPage" %>
Your views can choose to use the overall master page or the nested one as their masters.
Alternately, you can set the MasterPage of your views dynamically in several ways. The regular View() method has an overload to specify the master page:
return View("SomePage", "MasterPageFileHere");
or even better would be to specify an action method to do it for you globally. You can see a good walkthrough of that here.
精彩评论