Chapter 8. Working with Master Pages

Visual inheritance is a great new enhancement to your Web pages provided by new additions to ASP.NET 2.0. In effect, you can create a single template page that can be used as a foundation for any number of ASP.NET content pages in your application. These templates, called master pages, increase your productivity by making your applications easier to build and easier to manage after they are built. Visual Studio 2005 includes full designer support for master pages, making the developer experience richer than ever before. This chapter takes a close look at how to utilize master pages to the fullest extent in your applications and begins by explaining the advantages of master pages.

Why Do You Need Master Pages?

Most Web sites today have common elements used throughout the entire application or on a majority of the pages within the application. For instance, if you look at the main page of the Reuters News Web site (found at www.reuters.com), you see common elements that are used throughout the entire Web site. These common areas are labeled in Figure 8-1.

In this screen shot, notice a header section, a navigation section, and a footer section on the page. In fact, nearly every page within the entire application uses these same elements. Even before master pages, you had ways to put these elements into every page; but in most cases, doing so posed difficulties.

Some developers simply copy and paste the code for these common sections to each and every ...

Get Professional ASP.NET 2.0 Special Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.