SlideShare a Scribd company logo
1 of 18
Master Page
Master page allows you to create a consistent look and behaviour
for all the pages in your web applications . Master Page Design is
common for all the pages. Master page actually consists of two
pieces, the master page itself and one or more content pages..
A master page is an ASP.NET file with the extension .master.
ContentPlaceholder control, which defines a region on the master
page, is where the content pages can plug in page specific content.
 A Master Page enables user to share the same content among
multiple content pages in a website.
ASP.NET master pages allow user to create a consistent layout for
the pages in a application.
When users request the content pages, they merge with the master
page to produce output that combines the layout of the master page
with the content from the content page.
Master Page
 Master pages in ASP.NET Web Forms start with the @Masterdirective .
 The directive looks like the following.
<%@MasterLanguage="C#“CodeFile="MasterPage.master.cs"
Inherits="MasterPage" %>
 @Page directive that is used for ordinary .aspx pages.
 The directive looks like the following.
<%@PageLanguage="C#”
MasterPageFile="~/MasterPages/Master1.master"Title="Content
Page"%>
 To enable pages to insert content, the master page contains a placeholder
tag <asp:ContentPlaceHolder> for individual content.
Working with Master Page
1. To use master pages, first create a master page and add
tables and other common elements.
2. Add <ContentPlaceHolder> controls to the master page
from toolbox.
3. To create the content pages, add standard Web forms,
select the master page check box when creating the
page and then select the master page.
4. Add content to the page.
Creating a Master Page
 Step 1
Create new project in Visual Studio 2010
1. Go to File-> New-> Web Site-> Visual C#->ASP.NET
Website-> Entry Application Name-> OK
2. Create a new web site named MasterPageDemo.
3. Right click on website in Solution Explorer and Click
on Add New Item from pop up menu.
Creating Master Page
4. Add Master Page to the application named
“ MasterPage.master” and create design.
Source Code
Creating Master Page
Design
Creating Master Page
Step 2
5. In Solution Explorer, right click on website and click
on Add New Item and select web form from pop-up
window.
6. Change the name of the web form and select the check
box of Select Master Page then click on Add button.
Creating Master Page
7. Select the Masterpage.master and click on OK.
Creating Master Page
8. In content Page Index.aspx, user can use the content
place holder to add content to the page.
Add
Content
Here
Dynamically Loading Master Page
 Websites uses different master pages dynamically with
a content page depending upon the request.
 This features enables the users to customize the
appearance of the website by loading different master
pages. A menu of master pages allow our users to pick
their favourite layout.
Steps to create dynamically loading master page as
following:
1. Create two Master Page MasterPage2.master and
MasterPage3.master with one ContentPlaceHolder
in each.
MasterPage2.master
Source Code Design
MasterPage3.master
Source Code Design
2. Create a content page “DefaultPage4.aspx” using
MasterPage2.page as default master page.
3. User can switch between master pages using links on
the web page.
Advantages of Master Page
 They allow user to centralize the common functionality of
user pages so that user can make updates in just one
place.
 They make it easy to create one set of controls and code
and apply the results to a set of pages. For example, user
can use controls on the master page to create a menu that
applies to all pages.
 They give user fine-grained control over the lausert of the
final page by allowing user to control how the placeholder
controls are rendered.
 They provide an object model that allows user to
customize the master page from individual content pages.
Thank You

More Related Content

What's hot (20)

GRID VIEW PPT
GRID VIEW PPTGRID VIEW PPT
GRID VIEW PPT
 
Server Controls of ASP.Net
Server Controls of ASP.NetServer Controls of ASP.Net
Server Controls of ASP.Net
 
Introduction to ASP.NET
Introduction to ASP.NETIntroduction to ASP.NET
Introduction to ASP.NET
 
CSS
CSSCSS
CSS
 
Asp net
Asp netAsp net
Asp net
 
Asp.net server controls
Asp.net server controlsAsp.net server controls
Asp.net server controls
 
An Overview of HTML, CSS & Java Script
An Overview of HTML, CSS & Java ScriptAn Overview of HTML, CSS & Java Script
An Overview of HTML, CSS & Java Script
 
Servlets
ServletsServlets
Servlets
 
Introduction to ADO.NET
Introduction to ADO.NETIntroduction to ADO.NET
Introduction to ADO.NET
 
CSS ppt
CSS pptCSS ppt
CSS ppt
 
Java Server Pages(jsp)
Java Server Pages(jsp)Java Server Pages(jsp)
Java Server Pages(jsp)
 
Lab #2: Introduction to Javascript
Lab #2: Introduction to JavascriptLab #2: Introduction to Javascript
Lab #2: Introduction to Javascript
 
ASP.NET Web form
ASP.NET Web formASP.NET Web form
ASP.NET Web form
 
Ch 04 asp.net application
Ch 04 asp.net application Ch 04 asp.net application
Ch 04 asp.net application
 
ASP.NET 10 - Data Controls
ASP.NET 10 - Data ControlsASP.NET 10 - Data Controls
ASP.NET 10 - Data Controls
 
JavaScript - An Introduction
JavaScript - An IntroductionJavaScript - An Introduction
JavaScript - An Introduction
 
Android Layout
Android LayoutAndroid Layout
Android Layout
 
Java swing
Java swingJava swing
Java swing
 
Cascading Style Sheets (CSS) help
Cascading Style Sheets (CSS) helpCascading Style Sheets (CSS) help
Cascading Style Sheets (CSS) help
 
Cascading style sheets (CSS)
Cascading style sheets (CSS)Cascading style sheets (CSS)
Cascading style sheets (CSS)
 

Similar to Master page in Asp.net

Aspnet master pages_tutorial_10_cs
Aspnet master pages_tutorial_10_csAspnet master pages_tutorial_10_cs
Aspnet master pages_tutorial_10_csVaibhav Chavan
 
04 asp.net session05
04 asp.net session0504 asp.net session05
04 asp.net session05Vivek chan
 
04 asp.net session05
04 asp.net session0504 asp.net session05
04 asp.net session05Mani Chaubey
 
Advanced SharePoint 2013 Site Administration
Advanced SharePoint 2013 Site AdministrationAdvanced SharePoint 2013 Site Administration
Advanced SharePoint 2013 Site AdministrationLearning SharePoint
 
Master Pages In Asp.net
Master Pages In Asp.netMaster Pages In Asp.net
Master Pages In Asp.netparallelminder
 
11 asp.net session16
11 asp.net session1611 asp.net session16
11 asp.net session16Vivek chan
 
Creating Web Pages with Microsoft FrontPage - R.D.Sivakumar
Creating Web Pages with Microsoft FrontPage - R.D.SivakumarCreating Web Pages with Microsoft FrontPage - R.D.Sivakumar
Creating Web Pages with Microsoft FrontPage - R.D.SivakumarSivakumar R D .
 
ASP.NET 06 - Customizing Your Sites Appearance
ASP.NET 06 - Customizing Your Sites AppearanceASP.NET 06 - Customizing Your Sites Appearance
ASP.NET 06 - Customizing Your Sites AppearanceRandy Connolly
 
15 asp.net session22
15 asp.net session2215 asp.net session22
15 asp.net session22Vivek chan
 
04 asp.net session05
04 asp.net session0504 asp.net session05
04 asp.net session05Niit Care
 
Net4’s EasySite Builder Step by Step Guide
Net4’s EasySite Builder Step by Step GuideNet4’s EasySite Builder Step by Step Guide
Net4’s EasySite Builder Step by Step GuidePallavi Vyas
 
Net4’s EasySite Builder Step By Step Guide to Create Business Website
Net4’s EasySite Builder Step By Step Guide to Create Business WebsiteNet4’s EasySite Builder Step By Step Guide to Create Business Website
Net4’s EasySite Builder Step By Step Guide to Create Business WebsiteNet4 India Ltd.
 
BP304 - Blog It Up, Baby! Extending the new IBM Lotus Domino Blog Template
BP304 - Blog It Up, Baby! Extending the new IBM Lotus Domino Blog TemplateBP304 - Blog It Up, Baby! Extending the new IBM Lotus Domino Blog Template
BP304 - Blog It Up, Baby! Extending the new IBM Lotus Domino Blog TemplateSean Burgess
 
.NET 1.1 Base Page Framework Article
.NET 1.1 Base Page Framework Article.NET 1.1 Base Page Framework Article
.NET 1.1 Base Page Framework Articlebitburner93
 

Similar to Master page in Asp.net (20)

Aspnet master pages_tutorial_10_cs
Aspnet master pages_tutorial_10_csAspnet master pages_tutorial_10_cs
Aspnet master pages_tutorial_10_cs
 
Master pages
Master pagesMaster pages
Master pages
 
masterpages 1.pptx
masterpages 1.pptxmasterpages 1.pptx
masterpages 1.pptx
 
04 asp.net session05
04 asp.net session0504 asp.net session05
04 asp.net session05
 
04 asp.net session05
04 asp.net session0504 asp.net session05
04 asp.net session05
 
Advanced SharePoint 2013 Site Administration
Advanced SharePoint 2013 Site AdministrationAdvanced SharePoint 2013 Site Administration
Advanced SharePoint 2013 Site Administration
 
Chapter 12
Chapter 12Chapter 12
Chapter 12
 
Master Pages In Asp.net
Master Pages In Asp.netMaster Pages In Asp.net
Master Pages In Asp.net
 
11 asp.net session16
11 asp.net session1611 asp.net session16
11 asp.net session16
 
Creating Web Pages with Microsoft FrontPage - R.D.Sivakumar
Creating Web Pages with Microsoft FrontPage - R.D.SivakumarCreating Web Pages with Microsoft FrontPage - R.D.Sivakumar
Creating Web Pages with Microsoft FrontPage - R.D.Sivakumar
 
ASP.NET 06 - Customizing Your Sites Appearance
ASP.NET 06 - Customizing Your Sites AppearanceASP.NET 06 - Customizing Your Sites Appearance
ASP.NET 06 - Customizing Your Sites Appearance
 
15 asp.net session22
15 asp.net session2215 asp.net session22
15 asp.net session22
 
Master page
Master pageMaster page
Master page
 
04 asp.net session05
04 asp.net session0504 asp.net session05
04 asp.net session05
 
Net4’s EasySite Builder Step by Step Guide
Net4’s EasySite Builder Step by Step GuideNet4’s EasySite Builder Step by Step Guide
Net4’s EasySite Builder Step by Step Guide
 
Net4’s EasySite Builder Step By Step Guide to Create Business Website
Net4’s EasySite Builder Step By Step Guide to Create Business WebsiteNet4’s EasySite Builder Step By Step Guide to Create Business Website
Net4’s EasySite Builder Step By Step Guide to Create Business Website
 
Chapter 5 (master page)
Chapter 5 (master page)Chapter 5 (master page)
Chapter 5 (master page)
 
BP304 - Blog It Up, Baby! Extending the new IBM Lotus Domino Blog Template
BP304 - Blog It Up, Baby! Extending the new IBM Lotus Domino Blog TemplateBP304 - Blog It Up, Baby! Extending the new IBM Lotus Domino Blog Template
BP304 - Blog It Up, Baby! Extending the new IBM Lotus Domino Blog Template
 
.NET 1.1 Base Page Framework Article
.NET 1.1 Base Page Framework Article.NET 1.1 Base Page Framework Article
.NET 1.1 Base Page Framework Article
 
ASP.NET Lecture 3
ASP.NET Lecture 3ASP.NET Lecture 3
ASP.NET Lecture 3
 

Recently uploaded

History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfMahmoud M. Sallam
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 

Recently uploaded (20)

History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
Pharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdfPharmacognosy Flower 3. Compositae 2023.pdf
Pharmacognosy Flower 3. Compositae 2023.pdf
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 

Master page in Asp.net

  • 1.
  • 2. Master Page Master page allows you to create a consistent look and behaviour for all the pages in your web applications . Master Page Design is common for all the pages. Master page actually consists of two pieces, the master page itself and one or more content pages.. A master page is an ASP.NET file with the extension .master. ContentPlaceholder control, which defines a region on the master page, is where the content pages can plug in page specific content.  A Master Page enables user to share the same content among multiple content pages in a website. ASP.NET master pages allow user to create a consistent layout for the pages in a application. When users request the content pages, they merge with the master page to produce output that combines the layout of the master page with the content from the content page.
  • 3. Master Page  Master pages in ASP.NET Web Forms start with the @Masterdirective .  The directive looks like the following. <%@MasterLanguage="C#“CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>  @Page directive that is used for ordinary .aspx pages.  The directive looks like the following. <%@PageLanguage="C#” MasterPageFile="~/MasterPages/Master1.master"Title="Content Page"%>  To enable pages to insert content, the master page contains a placeholder tag <asp:ContentPlaceHolder> for individual content.
  • 4. Working with Master Page 1. To use master pages, first create a master page and add tables and other common elements. 2. Add <ContentPlaceHolder> controls to the master page from toolbox. 3. To create the content pages, add standard Web forms, select the master page check box when creating the page and then select the master page. 4. Add content to the page.
  • 5.
  • 6. Creating a Master Page  Step 1 Create new project in Visual Studio 2010 1. Go to File-> New-> Web Site-> Visual C#->ASP.NET Website-> Entry Application Name-> OK 2. Create a new web site named MasterPageDemo. 3. Right click on website in Solution Explorer and Click on Add New Item from pop up menu.
  • 7. Creating Master Page 4. Add Master Page to the application named “ MasterPage.master” and create design. Source Code
  • 9. Creating Master Page Step 2 5. In Solution Explorer, right click on website and click on Add New Item and select web form from pop-up window. 6. Change the name of the web form and select the check box of Select Master Page then click on Add button.
  • 10. Creating Master Page 7. Select the Masterpage.master and click on OK.
  • 11. Creating Master Page 8. In content Page Index.aspx, user can use the content place holder to add content to the page. Add Content Here
  • 12. Dynamically Loading Master Page  Websites uses different master pages dynamically with a content page depending upon the request.  This features enables the users to customize the appearance of the website by loading different master pages. A menu of master pages allow our users to pick their favourite layout. Steps to create dynamically loading master page as following: 1. Create two Master Page MasterPage2.master and MasterPage3.master with one ContentPlaceHolder in each.
  • 15. 2. Create a content page “DefaultPage4.aspx” using MasterPage2.page as default master page.
  • 16. 3. User can switch between master pages using links on the web page.
  • 17. Advantages of Master Page  They allow user to centralize the common functionality of user pages so that user can make updates in just one place.  They make it easy to create one set of controls and code and apply the results to a set of pages. For example, user can use controls on the master page to create a menu that applies to all pages.  They give user fine-grained control over the lausert of the final page by allowing user to control how the placeholder controls are rendered.  They provide an object model that allows user to customize the master page from individual content pages.