Master Pages in ASP.NET 2.0 drive uniform design

One of ASP.NET 2.0's most notable advancements is the Master Page, which lets developers create consistent headers, footers and logos across an entire Web app.

ASP.NET 2.0 offers many well-documented enhancements, from security controls and site administration tools to,

of course, code reductions. For anyone building a complex Web application for customers or employees, the most notable improvements can be found in the page framework. Here Microsoft has gone to great lengths to ensure that developers need to build something once and only once.

The Master Page construction aptly reflects this notion. A master page consists of common content, such as the banner across the top of a Web application, and a spot for content placeholders. (Content pages, conversely, reference master pages and fill the placeholders.)

"User interface design is left to the designers," said Patrick Hynds, CTO, CriticalSites, during a demo at Microsoft Launch event in Boston. "It's not something we have to wrap our minds around every day."

As outlined in the MSDN article Master Pages in ASP.NET 2.0, content pages have the same .aspx extension as typical ASP.NET files.

More on ASP.NET 2.0 development

ASP.NET 2.0 Learning Guide

ASP.NET 2.0 provides cleaner, developer-friendly coding

How to Use Master Pages -- Chapter 3 of Murach's ASP.NET 2.0 Upgrader's Guide, VB Edition

There are a couple differences, though. Everything on a content page needs to be contained within Content controls, which map content areas on the pages to the appropriate areas marked by a master page's ContentPlaceHolder control. In addition, a content page has to be associated with a Master Page through an attribute of the <%@ Page %> directive.

Content development gains a few timesavers, too, as Tony Pino of the Boston .NET User Group demonstrated when the group met in January. The easiest way to control and update an app, Pino said, is through themes.

Themes consist of a style sheet, images and a skin file, which defines styles for a specific server control (like the width of a text box) but does not affect the overall design of a Web app. Skins work well for defining advanced controls and collections and for displaying foreground images that can't be controlled by cascading style sheets, as Jeff King explained at Tech Ed.

Themes can be defined on a per-page basis, and a developer can always override a page's theme, Pino said. Also keep in mind that themes should not include global images or style sheets such as Print or Shared.

This MSDN article by Stephen Walther, Creating Web Application Themes in ASP.NET 2.0, offers more insight into constructing themes, deploying skins and incorporating both into cascading style sheets.

This was first published in January 2006

Dig deeper on ASP.NET development best practices

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

SearchCloudComputing

SearchSoftwareQuality

SearchSOA

TheServerSide

SearchCloudApplications

Close