O'Reilly logo

ASP.NET 2.0: A Developer's Notebook by Wei-Meng Lee

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Use a Master Page as a Content Page Template

Note

Using Master Pages and visual inheritance, you can give all your web site Content pages a common look and feel.

Once you've created a Master page, you can create Content pages for your site that use the Master page as a template.

How do I do that?

Note

A Content page is a Web Form that uses a Master page.

In this lab, you will add Content pages to your project and give them a consistent look and feel by using the Master page you created in the previous lab. You will then add controls to a Content page and see how ASP.NET combines the content of the Master page and Content pages at runtime.

  1. First, let's create some pages for your web site. Using the project created in the previous lab, add a new Web Form. Right-click the project name in Solution Explorer and select Add New Item.... On the Add New Item page, select Web Form and use its default name (Default2.aspx). Check the "Select master page" checkbox at the bottom of the dialog (see Figure 2-6).

    Creating a Content page by selecting a Master page

    Figure 2-6. Creating a Content page by selecting a Master page

  2. You will be asked to choose a Master page to use for your form. Select MasterPage.master (see Figure 2-7).

    Selecting a Master page

    Figure 2-7. Selecting a Master page

    Note

    A Content page can have only one Master page.

  3. Click OK and Visual Studio displays the new ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required