How to Use Master Pages (Conclusion) - How to use nested master pages
(Page 5 of 6 )
In some web applications, particularly large ones, one or more sections of the web site may have common formatting elements in addition to the elements that apply to the entire site. In that case, you can use nested master pages as described in the following topics.
How nested master pages work
Figure 3-10 shows how nested master pages might be used in the Halloween Store application. Here, a portion of the web site is devoted to presenting do-it-yourself project instructions that show the user how to create home-made Halloween decorations and props. In addition to the other elements from the master page, each of the pages in this section of the web site has an additional banner that displays the text “Do-It-Yourself Projects.”
To create this additional banner, a second master page named ProjectsMaster.master is used. The content page (in this example, Tombstone.aspx) specifies that its master page is ProjectsMaster.master. Like any other master page, the ProjectsMaster master page includes a content placeholder. However, unlike regular master pages, the ProjectsMaster master page also includes a Master directive that specifies the application’s main master page, MasterPage.master. Thus, ProjectsMaster.master is nested within MasterPage.master. As you can see, elements from all three pages— MasterPage.master, ProjectsMaster.master, and Tombstone.aspx—are combined to create the final page that’s sent to the browser.
A master page that’s nested within another master page is called a child master, and the master page it’s nested in is called a parent master. Note that a parent master can also be a child master. In other words, you can nest master pages more than one level deep. However, few applications require more than one level of nesting.
An application with nested master pages (figure 3-10)

Description
- Master pages can be nested. This lets you create elements that are common to all pages of a web site and other elements that are common to a subset of pages within the site.
- When you nest master pages, the content placeholder of one master page, called the parent master, holds another master page, called the child master.
Next: How to create nested master pages >>
More ASP.NET Articles
More By Murach Publishing
|
This article is excerpted from chapter three of the book Murach’s ASP.NET 2.0 Upgrader’s Guide: VB Edition, written by Anne Boehm and Joel Murach (Murach, 2005; ISBN: 1-890774-36-7). Check it out today at your favorite bookstore. Buy this book now.
|
|