Nested Master Pages in ASP.NET 3.5


Introduction

This article explains the improved designer for creating Nested Master pages in Visual Studio 2008 and ASP.NET 3.5. Nested Master pages are used when you are build a hierarchy of templates for your web site.

For Example your Enterprise may have the corporate style header and each of your department in your organization may have different templates styles there you can use nested master pages for designing the templates.

You did have this feature in ASP.NET 2.0 but you were not able to work out with the visuals in the designer.

Working with Nested Master pages in VS 2008 and ASP.NET 3.5 in a sample

  1. Create a New Web site in VS 2008 File, New Web site it looks like the following screen shot



  2. Create a Nested Master page to link the above master page by right clicking the web site and select add new item option dialogue box will appear from there select the NestedMasterPage template.



    NestedMasterPages allows you to link masterpages together.

     

    Select the Master page and click ok it will link to the selected masterpage.


     

    We have created the above NestedMasterPage for a Department. The new feature that you need to observe is you are able to see the visuals in designer where you can edit the content in NestedMasterPage and you can view the results immediately in designer.

  3. Now we are going to create a content page for this NestedMasterPage. Right click the project and select Add New Item the following dialogue box will appear
     


    Instead of selecting a Web Form, we have new option Web Content form template in VS 2008 select this template for creating the content page for the NestedMasterPage.

  4. The Nested Content Page will looks like the following


     

    This is basically representing the what we are going to see in browser by having the Global MasterPage, NestedMastePage and Content Page which really increasing the developer integrated design experience.


Similar Articles