Youre all set now! Loading FrontPage.aspx in your browser will generate the
output shown in Figure 4.12.
Figure 4.12. Using a master page
Although the example is simplistic, its easy to see the possibilities: you can create
many web forms based on this template very easily. In our case, the master page
contains a single ContentPlaceHolder, but it could have more. Also, the master
page can define some default content for display inside the ContentPlaceHolder
on pages whose web forms dont provide a Content element for that placeholder.
Using Cascading Style Sheets (CSS)
Its clear that controls make it easy for us to reuse pieces of functionality in
multiple places. For example, I cant imagine an easier way to add calendars to
many web forms than to use the Calendar web server control.
However, controls dont solve the problem of defining and managing the visual
elements of your web site. Modern web sites need constant updating to keep
them fresh, and its not much fun editing hundreds of pages by hand just to
change a border color, for example, and then having to check everything to ensure
that the changes are consistent. The process is even more painful if the client
wants a more serious update, like rearranging components on the pages.
The good news is that this maintenance work can be made a lot easier by planning
ahead, correctly following a few basic rules, and efficiently using the tools HTML
and ASP.NET offer you.
An essential tool for building reusable visual styles is CSS (Cascading Style
Sheets). HTML was initially designed to deliver simple text content, and paid
135
Using Cascading Style Sheets (CSS)

Get Build Your Own ASP.NET 2.0 Web Site Using C# & VB, Second 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.