master pages are a new feature introduced in ASP.NET 2.0 to help you reduce development time for Web applications by defining a single location to maintain a consistent look and feel in a site. Master pages allow you to design a template that can be used to generate a common layout for many pages in the application.
the primary goal of master pages is to avoid creating each page from scratch and having to repeat the layout code. Another benefit of using master pages is that if you want to change the layout of the pages in the application, you only have to update the master page rather than each individual page. This feature is somewhat similar to the Microsoft Windows Form technique of visual Inheritance, available with the original version of the .NET Framework, and is used for desktop application development.
a master page looks like any ordinary ASP.NET Web page, except for the extension (.master instead of .aspx) and some special controls and header fields. Master pages must contain one or more <asp:contentplaceholder> controls. These controls represent areas of replaceable content. Basically, anything that is not in a contentplaceholder will appear on any page that uses the master page.
visual Studio 2005 automatically creates most of this code for you, so you don''t have to write complex HTML code for your page layout. A master page must also include the following default source code:
<%@ master language="C#" compilewith="site.master.cs" classname="ASP.site_master" %><html><head runat="server"><title>Untitled Page</title></head><body> <form runat="server"> <asp:contentplaceholder id="ContentPlaceHolder1" runat="server"> </asp:contentplaceholder> </form></body></html>
other than these key changes, a master page can contain any HTML or control that can be found on a normal ASP.NET page.
although master pages and frames serve a similar purpose, master pages offer much more functionality. Unlike frames, using master pages allow you to: