Differences between a traditional ASP.NET page and a 2.0 Master Page

You create a Master Page in pretty much the same way as you create a normal ASP.NET page. A Master Page can contain the same Web controls, User controls, HTML content, and scripts that you would add to a standard ASP.NET page. There are three important differences between a Master Page and a normal ASP.NET page.
1. Master page should end in a .master extension

2. A Master Page includes a <%@ Master %> directive instead of the normal <%@ Page %> directive. The <%@ Master %> directive supports many of the same attributes as the <%@ Page %> directive. For example, you can specify the programming language of the page with the directive <%@ Master Language=”vb” %>.

3. A Master Page and a normal ASP.NET page is that a Master Page can contain zero or more ContentPlaceHolder controls. A ContentPlaceHolder control can be used only within a Master Page. This control marks an area of a Master Page that can be overridden by a particular content page.

Listing 1. Simple.master

<%@ Master %>

id=”ContentPlaceHolder1″
runat=”server” />
id=”ContentPlaceHolder2″
runat=”server” />

Listing 2. Simple.aspx

<%@ Page MasterPageFile=”~/Simple.master” %>

ID=”Content1″
ContentPlaceHolderID=”ContentPlaceHolder1″
Runat=”server”>
Content in Left Column

ID=”Content2″
ContentPlaceHolderID=”ContentPlaceHolder2″
Runat=”server”>
Content in Right Column