15.02.2015 Views

C# 4 and .NET 4

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Master Pages ❘ 1195<br />

protected void cycleButton_Click(object sender, EventArgs e)<br />

{<br />

rainbowLabel1.Cycle();<br />

}<br />

code snippet PCSCustomCWebSite1/Default.aspx.cs<br />

Now you can view the sample <strong>and</strong> cycle the colors in the sample text, as shown in Figure 41-4.<br />

figure 41-4<br />

You can do a lot more with custom controls; indeed, the possibilities are practically limitless, but you will<br />

have to experiment with these possibilities on your own.<br />

masTer Pages<br />

Master pages provide an excellent way to make your web sites easier to design. Putting all (or at least most)<br />

of your page layout in a single file allows you to concentrate on the more important things for the individual<br />

web pages of your site.<br />

Master pages are created in files with the extension .master, <strong>and</strong> can be added via the Website ➪ Add New<br />

Item ... menu item, like any other site content. At first glance, the code generated for a master page is much<br />

like that for a st<strong>and</strong>ard .aspx page:<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

The differences are:<br />

➤<br />

➤<br />

➤<br />

A directive is used instead of a directive, although the attributes are<br />

the same.<br />

A ContentPlaceHolder control with an ID of head is placed in the page header.<br />

A ContentPlaceHolder control with an ID of ContentPlaceHolder1 is placed in the page body.<br />

www.it-ebooks.info

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!