Using ASP.NET Master Pages

The first approach to styling we will explore is the ASP.NET master page feature, which lets us apply a common design to pages using a system of templates. The master page feature is the reason we created an ASP.NET Web Application project, instead of the ASP.NET Empty Web Application we have relied on so far; when using this type of project, Visual Studio creates some default pages that use the master page feature. If you open the Default.aspx file and look at the markup, you will see that it has a different structure from the web pages we have seen so far, as illustrated by Listing 9-1.

Listing 9-1. The Default.aspx file

<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" ...

Get Applied ASP.NET 4 in Context now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.