Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Build Your Own ASP.NET 2.0 Web Site Using CSharp And VB (2006) [eng]-1.pdf
Скачиваний:
142
Добавлен:
16.08.2013
Размер:
15.69 Mб
Скачать

Using Cascading Style Sheets (CSS)

You’re 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, it’s 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 don’t provide a Content element for that placeholder.

Using Cascading Style Sheets (CSS)

It’s clear that controls make it easy for us to reuse pieces of functionality in multiple places. For example, I can’t imagine an easier way to add calendars to many web forms than to use the Calendar web server control.

However, controls don’t 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 it’s 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