Thursday, September 23, 2010

Nested Master Pages in .net 3.5

Note: Replace ! with <>

Step:1

File--*New--*website--*ASP.net website--*Solution explorer

Right Click on Project--*Add New Item---*Master Page
(Name=Parent_MasterPage.master,select CheckBox "place Code in Seperate File",Unselect CheckBox "Select Master Page")
Source view:
Remove all content from form tag and paste the below source view:
Note: Replace ! with <
and * with >
!div*
!h4*Parent master Page!/h4*
!br /*
!asp:Image ID="Image1" runat="server"
DescriptionUrl="~/Images/trial header.bmp" Height="122px"
ImageUrl="~/Images/trial header.bmp" Width="905px" /*
!p* !/p*
!asp:ContentPlaceHolder id="Parent_ContentPlaceHolder" runat="server"*
!/asp:ContentPlaceHolder*
!b*Footer of Parent Master Page:!/b*
mailto*copy Right Act 1984
!/div*

Step:2
Cretation of Master page 2nd.

Right Click on Project--*Add New Item---*Master Page(Name=Child_MasterPage.master,select CheckBox "place Code in Seperate File",select CheckBox "Select Master Page")


Source view
:
Note: Replace ! with <
and * with >
!%* Master Language="C#" MasterPageFile="~/Parent_MasterPage.master" %*
!asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server"*
!/asp:Content*
!asp:Content ID="Content2" ContentPlaceHolderID="Parent_ContentPlaceHolder" Runat="Server"*
!asp:Panel ID="Panel1" BackColor="AliceBlue" runat="server"*
!b*Child Master Page!/b*
!br /*
!asp:Image ID="Image1" runat="server" Height="125px" ImageUrl="~/Images/mid_big.gif" Width="787px" /*
!br /*
!asp:ContentPlaceHolder ID="Child_CP1" runat="server" *
!/asp:ContentPlaceHolder*
!b*Footer of Child Master Page:!/b*
mailto*copy Right Act 2001
!/asp:Panel*
!/asp:Content*
Step:3

Right Click on Project--*Add New Item---*Web Form(Name=Default2.aspx,select CheckBox "place Code in Seperate File",select CheckBox "Select Master Page")
Click on Add button:
Among both master pages ,Select Child_MasterPage.master

Replace the Source view of Default2.aspx with this:
Note: Replace ! with <
and * with >
!%* Page Title="" Language="C#" MasterPageFile="~/Child_MasterPage.master" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %*
!asp:Content ID="Content1" ContentPlaceHolderID="Child_CP1" Runat="Server"*
This is Content page derived from a Nested master Page:
U can Put ur Controls here.
!asp:Image ID="Image1" runat="server" Height="385px"
ImageUrl="~/Images/innerpage1_dataentry.jpg" Width="635px" /*
!/asp:Content*

Set Default2.aspx as start page and run the application.
Note: Please give a valid image url as per ur convenient.

No comments: