SP.NET 2.0 introduces a new concept known as Master Pages, in which you create a common base master file that provides a consistent layout for multiple pages in your application. To create a Master Page, you identify common appearance and behavior factors for the pages in your application, and move those to a master page. In the master page, you add placeholders called ContentPlaceHolders where the content (child) pages will insert their custom content. When users request the content pages, ASP.NET merges the output of the content pages with the output of the master page, resulting in a page that combines the master page layout with the output of the content page. In this article, you’ll take a look at the theory behind the master pages and see how to leverage the new Master Pages feature in a Web application. Along the way, you’ll also see some of the advanced concepts of master pages, such as accessing master page controls from code in content pages, nesting master pages, and configuring master page for an entire Web application.
Master Pages Architecture To use Master Pages in your ASP.NET Web application, you create a Master Page for the site layout and design and create Content Pages for each content resource, and then connect the content pages to the master pages using the new controls and attributes supplied by ASP.NET 2.0. After you make that connection, ASP.NET will serve up the page by merging the content from the master page with the content of the content pages.
What You Need
The Master Pages feature is available only in ASP.NET 2.0, which ships with Visual Studio.NET Whidbey, Alpha Edition or later.
The master page defines content areas using the ContentPlaceHolder control, and the content pages place their content in the areas identified by the ContentPlaceHolder control in the master page. Pages that use a master page to define the layout may place content only in the areas defined by the ContentPlaceHolder, thus ensuring a consistent site design. Master pages have a .master file extension. Apart from the content required to define the standard look and feel of the application, the master pages also contain all the top-level HTML elements for a page, such as ,