Examining Master Pages

Download this episode

Download Video

Description

Over the years Web developers have struggled with a variety of techniques to try and create template based sites. Unfortunately, none of these have been generic and easy to maintain. The introduction of Master pages is designed to solve this problem.

Conceptually master pages consist of two elements: Master Page and Content Page. Master pages act as the templates for the Content Pages, and Content Pages provide content to populate pieces of Master Pages. A Master Page is essentially a standard ASP.NET page except that it used the extension of .master and a <%@ master %> directive instead of <%@ page %>. This Master Page file serves as the template for other pages, so typically it will contain the top-level HTML elements, the main form, headers, footers, and such. Within the Master Page you add instances of the ContentPlaceHolder control at locations where you want Content Pages to supply page-specific content.

The Content Pages are just ordinary .aspx files that specify an associated Master Page in their page directive using the masterpagefile attribute. These pages contain only instances of the Content control as they are used to to supply content for the inherited Master Page template. Each Content control must map to a specific ContentPlaceHolder control defined in the referenced Master Page, the contents of which is inserted into the Master Page's placeholder at rendering time.


In this screencast,
Thom examines some of the uses for Master Pages.

Embed

Format

Available formats for this video:

Actual format may change based on video formats available and browser capability.

    The Discussion

    • User profile image
      Phanindra
      Great Introduction to Master Pager. I liked your emphasis on FindControl, I am begining to understand the importance of this. I only wishes if you had shown an example eploiting the full capabilities of the Master Pages. This could give us a clear vision as to how far we could take this in our application development effort.

      Many Thanks

    Comments closed

    Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.