Datasheet
Using these features, you can spend your time building richer, more fully featured applications by lever-
aging the new controls and infrastructure services built into the core platform, as opposed to writing a
lot of infrastructure code as is the case with ASP.NET 1.x. For example, ASP.NET 2.0 now includes built-
in support for membership (username/password credential storage) and role management services out
of the box. The new personalization service provides for quick storage/retrieval of user settings and
preferences, enabling rich customization with minimal code. With ASP.NET 2.0, Microsoft has intro-
duced a new concept known as master pages that now enable flexible page user interface (UI) inheri-
tance across sites. The new site navigation system enables developers to quickly build link structures
consistently across a site. Site counters enable rich logging and instrumentation of client browser access
patterns. Themes enable flexible UI skinning of controls and pages. And the new ASP.NET Web Part
Framework enables rich portal-style layout and end user customization features that would require tens
of thousands of lines of code to write today. Along with all these features, ASP.NET 2.0 also brings with
it 45 new server controls that enable powerful declarative support for data access, login security, wizard
navigation, image generation, menus, treeviews, portals, and more. The next few sections will provide
you with a glimpse of these features.
Master Pages
ASP.NET 2.0 introduces a new concept known as master pages, in which a common base master file con-
tains the common look and feel and standard behavior for all the pages in your application. Once the
common content is placed in the master page, the content pages (child pages) can inherit content from
the master pages apart from adding their content to the final output. To allow the content page to add its
own content, you add placeholders (known as
ContentPlaceHolder control) in the master page that
will be utilized by the content pages to add their custom content. When users request the content pages,
the output of the content pages are merged with the output of the master page, resulting in an output
that combines the layout of the master page with the output of the content page.
Master pages are saved with the file extension
.master. Apart from containing all the contents that are
required for defining the standard look and feel of the application, the master pages also contain all the
top-level HTML elements for a page, such as
<html>, <head>, and <form>. As mentioned previously,
the master pages also contain one or more content placeholders that are used to define regions that will
be rendered through the content pages.
Now that you have had a general understanding of master pages, take a look at an example. First, create
a master page named
CommonPage.master and add the code shown in Listing 1-1.
Listing 1-1: A Master Page Example
<%@ master language=”C#” %>
<html>
<head runat=”server”>
(continued)
In ASP.NET 1.x, you could achieve similar effects by creating user controls that
abstract the common look and behavior of all the pages in the application and then
declaring the user control in each and every page. Even though this approach was
useful, it required a lot of cutting and pasting of code across all the pages in a web
application. Master pages take this approach of reusable user controls to the next
level by providing a much cleaner approach to reusing a common look and feel
across all the pages.
5
Chapter 1: Introduction to ASP.NET 2.0
05_041796 ch01.qxp 12/29/06 9:09 PM Page 5