Examining Master Pages
- Posted: Dec 18, 2005 at 4:51PM
- 16,442 views
- 1 comment
Loading user information from Channel 9
Something went wrong getting user information from Channel 9
Loading user information from MSDN
Something went wrong getting user information from MSDN
Loading Visual Studio Achievements
Something went wrong getting the Visual Studio Achievements
Right click “Save as…”
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.