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 ❘ 1197<br />

nested master Pages<br />

The “Select master page” option is also available when you create a new master page. By using this option,<br />

you can create a nested master page that is based on a parent master page. For example, you can create a<br />

master page called MyNestedMasterPage that uses MyMasterPage as follows:<br />

<br />

<br />

<br />

<br />

<br />

First nested place holder:<br />

<br />

<br />

<br />

<br />

Second nested place holder:<br />

<br />

<br />

<br />

Pages that use this master page would supply content for NestedContentPlaceHolder1 <strong>and</strong><br />

NestedContentPlaceHolder2, but would not have direct access to the ContentPlaceHolder controls<br />

specified in MyMasterPage. In this example, MyNestedMasterPage fixes the content for the head control<br />

<strong>and</strong> supplies a template for the ContentPlaceHolder1 control.<br />

By creating a family of nested master pages, you can provide alternate layouts for pages while leaving some<br />

aspects of the base master pages untouched. For example, the root master page might include navigation <strong>and</strong><br />

basic layout, <strong>and</strong> nested master pages could provide layouts with different amounts of columns. You could<br />

then use the nested master pages in the pages of your site <strong>and</strong> quickly switch between these alternate layouts<br />

on different pages.<br />

master Pages in PCsdemosite<br />

In PCSDemoSite, the single master page MasterPage.master (the default name for a master page) is used,<br />

with code as follows:<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

www.it-ebooks.info

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

Saved successfully!

Ooh no, something went wrong!