![]() |
Web Development »
ASP.NET »
General
Intermediate
License: The Code Project Open License (CPOL)
Nested Master Page in VS 2008By Ashrafur RahamanIn visual studio 2008 nested master page concept is introduced, to make page template |
C#, .NET (.NET 3.5), ASP.NET, Dev
|
||||||||||
|
Advanced Search Add to IE Search |
|
|
|
||||||||||||||||

Here is the code of parent master page
<asp:Content ID="Content1" ContentPlaceHolderID="contentMain" Runat="Server"> <div id="twoColumn"> <table width="100%"> <tr><td style="width:20%"> <asp:ContentPlaceHolder ID="leftColumn" runat="server"> </asp:ContentPlaceHolder> </td><td style="width:80%"> <asp:ContentPlaceHolder ID="rightColumn" runat="server"> </asp:ContentPlaceHolder> </td></tr> </table> </div> </asp:Content>

Here is the code of one column child master page
<asp:Content ID="Content1" ContentPlaceHolderID="contentMain" Runat="Server"> <asp:ContentPlaceHolder ID="oneColumnContent" runat="server"> </asp:ContentPlaceHolder> </asp:Content>
Here is the code of two column child master page
<asp:Content ID="Content1" ContentPlaceHolderID="contentMain" Runat="Server"> <div id="twoColumn"> <table width="100%"> <tr><td style="width:20%"> <asp:ContentPlaceHolder ID="leftColumn" runat="server"> </asp:ContentPlaceHolder> </td><td style="width:80%"> <asp:ContentPlaceHolder ID="rightColumn" runat="server"> </asp:ContentPlaceHolder> </td></tr> </table> </div> </asp:Content>
Now you have two templates for your web site one template is one column and another template is two columns (left and main). Just add web page in your web site and select what template you need for page and use it.
For one column web page code will like that
<asp:Content ID="Content1" ContentPlaceHolderID="oneColumnContent" Runat="Server"> //Enter all the contents of page here </asp:Content>
For two column web page code will like that
<asp:Content ID="Content1" ContentPlaceHolderID="leftColumn" Runat="Server"> //Enter data of left content here </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="rightColumn" Runat="Server"> //Enter all the Contents of page here </asp:Content>
Now it is easy to make your website template using nester master page so enjoy make your master pages web site template.
Happy Coding :)
I was working in a project using asp.net 3.5 and for some interesting UI problem solving have used nested master page. Its fun to using that.
| You must Sign In to use this message board. | ||||||||
|
||||||||
|
||||||||
|
||||||||
|
||||||||
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 9 Feb 2008 Editor: |
Copyright 2008 by Ashrafur Rahaman Everything else Copyright © CodeProject, 1999-2009 Web15 | Advertise on the Code Project |