Saturday, January 24, 2009

Nested Master Page [LEVEL:: EASY]

“Nested master pages are supported since ASP.NET 2.0. The catch is that Visual Studio 2005 didn't support the design of nested masters very well. Thankfully, this capability changes radically with Visual Studio 2008, where nested master pages are fully supported in the page designer.” Reference: Programming Microsoft ASP.NET 3.5
by Dino Esposito MS Press

There are techniques for master pages to modify/improve their behavior based on the requirements of an ASP.NET project. This post shows how to nest one master page inside another.

In the following picture, the first line is written in a master page that is used as the top level master page, the second line is written in a nested master page (level 2) and the third line and the title of the page are written in an aspx file that uses our nested master page as it master page:

The source in the top level master page called MP_Level1:



The source in the nested master page called MP_Level2_No1:


And this is the source of the aspx file:


No comments:

Post a Comment