|
|||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||
|
Announcements
Chapters
Services
Feature Zones
|
Note: This is an unedited contribution. If this article is inappropriate,
needs attention or copies someone else's work without reference then please
Report This Article
IntroductionUsing master page was one of the famous features in ASP.NET 2.0. It is great news for developer that Visual Studio 2008 has introduced nested master page concept. You can nest master pages so master page can have flexible layout. Using nested master page we can make website template. In this article there is a small implementation of such page template.works through
Create Web SiteIn visual studio 2008 and a new web site using file system or local IISCreate Parent master page
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> Create one column child master page
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> Create two column child master page
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> Master template in you web pagesNow 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> Points of InterestNow it is easy to make your website template using nester master page so enjoy make your master pages web site template. Happy Coding :) HistoryI 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.
|
||||||||||||||||||||||||||||||||||||||||