Master Pages
Hi in this post let me explain what is Master Page in ASP.NET and in couple of days I will also post the similar concept how to do in J2EE and PHP.
It is a template page that can be used as a foundation for any number of ASP.NET content pages in your application. In working with master pages, you create a master file that is the template referenced by a subpage or content page. Master pages use a .master file extension, whereas content pages use the .aspx file extension you’re used to; but content pages are declared as such within the file’s Page
Creating a Master Page
- <form id="form2" runat="server">
- <div id="topContent">
- <h1><center>NPN Training</center></h1>
- </div>
- <div id="mainContent">
- <asp:ContentPlaceHolder id="MainContent" runat="server">
- </asp:ContentPlaceHolder>
- </div>
- <div id="leftContent">
- <p style="text-align: center;">
- <asp:Label ID="DateDisplay" runat="server"></asp:Label>
- </p>
- <h3>Sessions I</h3>
- <ul>
- <li>Intoduction</li>
- </ul>
- <h3>Session II</h3>
- <ul>
- <li>Master Pages</li>
- </ul>
- </div>
- <div id="footerContent">
- <img src="Images/PoweredByASPNET.gif" alt="Powered by ASP.NET!" />
- </div>
- </form>
Now let us create content page Right click the project add new item and from the dialog window select web form.
<h2>
About the Author</h2>
<p>
Hello! My name is Naveen
<p>
My primary experience lies in Web development with Microsoft technologies.</p>
</asp:Content>
Specifying the Title, Meta Tags, and Other HTML Headers in the Master Page
By default, two ContentPlaceHolder controls is created when we create a master page:
The head ContentPlaceHolder enables pages to add custom content to the <head> section.
- <head runat="server">
- <title>Untitled Page</title>
- <asp:ContentPlaceHolder id="head" runat="server">
- </asp:ContentPlaceHolder>
- <link href="Styles.css" rel="stylesheet" type="text/css" />
- </head>
The purpose of ContentPlaceHolder1 is to define a region in the Web Form that can be customized on a page-by-page basis.
<form id="" runat="server">
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</form>
one named head, and located in the <head> element; and one named ContentPlaceHolder1, placed within the Web Form. The purpose of ContentPlaceHolder1 is to define a region in the Web Form that can be customized on a page-by-page basis. The head ContentPlaceHolder enables pages to add custom content to the <head> section.
Specifying which Master Page to use
Specifying which Master Page to use in web.config
<controls>
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</controls>
</pages>
Specifying the Master Page for a specific folder
<system.web >
<pages masterPageFile="~/SiteReplicate.master">
</pages >
</system.web>
</location>
Setting the Page’s Title Declaratively
A content page’s title can be set declaratively through the Title attribute of the <%@ Page %> directive. This property can be set by directly modifying the <%@ Page %> directive or through the Properties window. Let’s look at both approaches.
The page’s title may also be set from the Properties window. From the Properties window, select DOCUMENT from the drop-down list to load the page-level properties, which includes the Title property.
Setting the Page’s Title Programmatically
{
Page.Title = string.Format("{0:d}", DateTime.Now);
}

hello Naveen i need .net material ra…send me as soon as possible k na…dnt forget to send me the material..i need it my dear
Hey naveen………… its very nice to see ur posts