Creating a Nested Master Page - What can go wrong?
(Page 4 of 4 )
It is important that you establish the container and the contents correctly, otherwise you may have unexpected results. The following shows the relationships that must exist for the above displayed pages:
Master (Parent) has a ContentPlaceHolder1
------------------------------------------------------------------
First Child (FChild):
Content's ContentPlaceHolderID=ContentPlaceHolder1
ContentPlaceHolder ID=Content1
Second Child (SChild):
Content's ContentPlaceHolderID=ContentPlaceHolder1
ContentPlaceHolder ID=Content2
-------------------------------------------------------------------
Mpage.aspx points to -->MasterPageFile="~/top.master"
FPage.aspx points to--->MasterPageFile="~/FChild.master", Content1
SPage.aspx points to--->MasterPageFile="~/SChild.master", Content2
However the good news is that you get ample help from drop-down cues and only the appropriate control will be shown as seen in the next picture when the developer is about to set the MasterPageFile. Presently he is trying to set this attribute for the MPage.aspx which should be top.master from the drop-down.

Summary
The Master Page feature in ASP.NET 2.0 makes it very easy to create web pages which have a consistent look and feel. The other features like web wizard, themes, skins, and so forth make it extremely useful for composing rich web pages. Nested pages are an example of visual inheritance and shown only for one level of nesting, but nesting can be extended for more levels as well.
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |