SIGN UP MEMBER LOGIN:    
ARTICLE

Working with Master Page in ASP.NET 2.0

Posted by Prabakar Samiyappan Articles | ASP.NET Programming November 06, 2006
This article gives you a step by step method of working with master page in ASP.NET 2.0.
Reader Level:

Master page:

 

The Master page is like that of the inherited form in Windows.NET. It is nothing but when you want to get the common look and feel of the particular part of your web we can go for master page.

 

For example:  You may have a common header and footer or the user information in the entire page in the same format we can go for the master page concept.

 

It reduce much of your coding. We don't want to redo the same design in the entire page. And the highlight is when you change in the master page it will be automatically reflected in all the inherited forms. Now it becomes easy to maintain.

 

Now we will see how to work with master page. Here are the steps

 

Short Introduction about .NET 2005

 

Here the concept of IIS is partially eliminated instead we can create a web application in the ordinary directory as like that of windows application. The .net itself will take care of IIS i.e. internally it will create a database that will take care of IIS work. 

  • We can also create the web application as our .net 2003 in IIS
  • We have the provision to create the application in FTP also.
  • Lot of new controls has been introduced like login controls, Web Parts etc.
  • It reduces much of the programmers work. The coding is much easy  

Creating a Master Page

 

1. Open a new solution and include Masterpage2.master as in (Ref: Figure 1)  

 

Figure1

 

Figure 1

 

2. The master page will be included as follows in the solution (Ref: Figure 2)

 

Figure2

Figure 2

 

3. Now make a design in the Masterpage2.master (Ref: Figure 3)

 

Figure3

 

Figure 3

 

4. Now master page has been added and designed. Now try to add a new web page and inherit the masterpage2.master as shown in (Ref : Figure 4.1). While adding a new page make sure that the  "Select Master Page" check box has been checked as shown in the figure 4.1

 

Figure4.1

 

5. Now select the master page which you need to be inherited in the webpage (Ref: Figure 5)

 

Figure 5

 

Figure 5

 

6. Now the default 4.aspx the content of the masterpage2.master id inherited (Ref: Figure 6)

 

Figure6

 

Figure 6

 

7. Set the startup page as default4.aspx and run your application now you can see the content of the masterpage2.master in default.aspx ( Ref : Figure 7)

 

Figure7

 

Figure 7

 

Now when you open the default4.aspx code you can clearly see that the masterpage2.master class has been inherited. This is the way we achieve master paging in .net 2005 . 

Login to add your contents and source code to this article
share this article :
post comment
 

Master page can be inherits in to content page so u compile the content page the master page will automatically get compiled.

Posted by Puneet Sharma Feb 26, 2010

Hi  Jak

There is no need of execute master page. They are inherite on the page on which you want.

For example:

<%@ Page Language="C#" MasterPageFile="~/MasterPageName.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default"  %>

Posted by Purushottam Rathore Apr 03, 2009

how will i execute

Posted by jak singh Feb 19, 2009
Team Foundation Server Hosting
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications. Visit DynamicPDF here
Nevron Gauge for SharePoint
Become a Sponsor