1) A master page provides a framework in which the content of each page on a web site is presented. Master pages make it easy to create pages that have a consistent look.
2) The pages that provide the content that’s displayed in a master page are called content pages .
3) The content of each content page is displayed in the master page’s content placeholder.
Yes We can add more than one master page to our web application
A nested master page is a master page associated with another master page. To create a nested master page, set the MasterPageFile attribute of the @Master directive to the name of the .master file of the base master page.
A Master page offers a template for one or more web forms. It defines placeholders for the content, which can be overridden by the content pages. The content pages contains only content. When users request the content page, ASP.NET merges the layout of the master page with the content of the content page and produce output.
If we add the theme attribute to the @ Master directive, the page will raise an error when it runs.
But we can apply themes by using the following approaches:-
- As master pages is placeholder/templated and it is merged with the content page very early in the page execution life-cycle. The theme that is applied to the the content pageis applied to the master page as well.
- If the site as a whole is configured to use a theme by including a theme definition in the pages element.
Hence there is no theme attribute in the @Master directive.
You can assign the master page dynamically with the help of Page class property called MasterPageFile . You can assign this when the page is in PreInit stage. Below is the sample code to assign master page dynamically.
void Page_PreInit(Object sender, EventArgs e)
this.MasterPageFile = "~/MasterPage.master";