尊敬的 微信汇率:1円 ≈ 0.046166 元 支付宝汇率:1円 ≈ 0.046257元 [退出登录]
SlideShare a Scribd company logo
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

Asp.net state management
Asp.net state managementAsp.net state management
Asp.net state management
priya Nithya
 
Introduction to Angularjs
Introduction to AngularjsIntroduction to Angularjs
Introduction to Angularjs
Manish Shekhawat
 
Jsp ppt
Jsp pptJsp ppt
Jsp ppt
Vikas Jagtap
 
Bootstrap
BootstrapBootstrap
Bootstrap
Jadson Santos
 
Web forms in ASP.net
Web forms in ASP.netWeb forms in ASP.net
Web forms in ASP.net
Madhuri Kavade
 
Session tracking in servlets
Session tracking in servletsSession tracking in servlets
Session tracking in servlets
vishal choudhary
 
Introduction to CSS3
Introduction to CSS3Introduction to CSS3
Introduction to CSS3
Doris Chen
 
Java script errors &amp; exceptions handling
Java script  errors &amp; exceptions handlingJava script  errors &amp; exceptions handling
Java script errors &amp; exceptions handling
AbhishekMondal42
 
Introduction to ASP.NET
Introduction to ASP.NETIntroduction to ASP.NET
Introduction to ASP.NET
Rajkumarsoy
 
ASP.NET MVC.
ASP.NET MVC.ASP.NET MVC.
ASP.NET MVC.
Ni
 
Jsp chapter 1
Jsp chapter 1Jsp chapter 1
Jsp chapter 1
kamal kotecha
 
Computer Science:Java jdbc
Computer Science:Java jdbcComputer Science:Java jdbc
Computer Science:Java jdbc
St Mary's College,Thrissur,Kerala
 
Javascript basics
Javascript basicsJavascript basics
Javascript basics
shreesenthil
 
Ajax
AjaxAjax
Ajax
Tech_MX
 
Css selectors
Css selectorsCss selectors
Css selectors
Parth Trivedi
 
Asp.net.
Asp.net.Asp.net.
Asp.net.
Naveen Sihag
 
Developing an ASP.NET Web Application
Developing an ASP.NET Web ApplicationDeveloping an ASP.NET Web Application
Developing an ASP.NET Web Application
Rishi Kothari
 
Database Connectivity in PHP
Database Connectivity in PHPDatabase Connectivity in PHP
Database Connectivity in PHP
Taha Malampatti
 
Basic html structure
Basic html structureBasic html structure
Basic html structure
Jhaun Paul Enriquez
 
Introduction of Html/css/js
Introduction of Html/css/jsIntroduction of Html/css/js
Introduction of Html/css/js
Knoldus Inc.
 

What's hot (20)

Asp.net state management
Asp.net state managementAsp.net state management
Asp.net state management
 
Introduction to Angularjs
Introduction to AngularjsIntroduction to Angularjs
Introduction to Angularjs
 
Jsp ppt
Jsp pptJsp ppt
Jsp ppt
 
Bootstrap
BootstrapBootstrap
Bootstrap
 
Web forms in ASP.net
Web forms in ASP.netWeb forms in ASP.net
Web forms in ASP.net
 
Session tracking in servlets
Session tracking in servletsSession tracking in servlets
Session tracking in servlets
 
Introduction to CSS3
Introduction to CSS3Introduction to CSS3
Introduction to CSS3
 
Java script errors &amp; exceptions handling
Java script  errors &amp; exceptions handlingJava script  errors &amp; exceptions handling
Java script errors &amp; exceptions handling
 
Introduction to ASP.NET
Introduction to ASP.NETIntroduction to ASP.NET
Introduction to ASP.NET
 
ASP.NET MVC.
ASP.NET MVC.ASP.NET MVC.
ASP.NET MVC.
 
Jsp chapter 1
Jsp chapter 1Jsp chapter 1
Jsp chapter 1
 
Computer Science:Java jdbc
Computer Science:Java jdbcComputer Science:Java jdbc
Computer Science:Java jdbc
 
Javascript basics
Javascript basicsJavascript basics
Javascript basics
 
Ajax
AjaxAjax
Ajax
 
Css selectors
Css selectorsCss selectors
Css selectors
 
Asp.net.
Asp.net.Asp.net.
Asp.net.
 
Developing an ASP.NET Web Application
Developing an ASP.NET Web ApplicationDeveloping an ASP.NET Web Application
Developing an ASP.NET Web Application
 
Database Connectivity in PHP
Database Connectivity in PHPDatabase Connectivity in PHP
Database Connectivity in PHP
 
Basic html structure
Basic html structureBasic html structure
Basic html structure
 
Introduction of Html/css/js
Introduction of Html/css/jsIntroduction of Html/css/js
Introduction of Html/css/js
 

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_cs
Vaibhav Chavan
 
Master pages
Master pagesMaster pages
Master pages
Paneliya Prince
 
masterpages 1.pptx
masterpages 1.pptxmasterpages 1.pptx
masterpages 1.pptx
SANJUSANJEEVTOPPO
 
04 asp.net session05
04 asp.net session0504 asp.net session05
04 asp.net session05
Vivek chan
 
04 asp.net session05
04 asp.net session0504 asp.net session05
04 asp.net session05
Mani Chaubey
 
Advanced SharePoint 2013 Site Administration
Advanced SharePoint 2013 Site AdministrationAdvanced SharePoint 2013 Site Administration
Advanced SharePoint 2013 Site Administration
Learning SharePoint
 
Chapter 12
Chapter 12Chapter 12
Master Pages In Asp.net
Master Pages In Asp.netMaster Pages In Asp.net
Master Pages In Asp.net
parallelminder
 
11 asp.net session16
11 asp.net session1611 asp.net session16
11 asp.net session16
Vivek 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.Sivakumar
Sivakumar 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 Appearance
Randy Connolly
 
15 asp.net session22
15 asp.net session2215 asp.net session22
15 asp.net session22
Vivek chan
 
Master page
Master pageMaster page
Master page
Paneliya Prince
 
04 asp.net session05
04 asp.net session0504 asp.net session05
04 asp.net session05
Niit 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 Guide
Pallavi 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 Website
Net4 India Ltd.
 
Chapter 5 (master page)
Chapter 5 (master page)Chapter 5 (master page)
Chapter 5 (master page)
let's go to study
 
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
Sean 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 Article
bitburner93
 
ASP.NET Lecture 3
ASP.NET Lecture 3ASP.NET Lecture 3
ASP.NET Lecture 3
Julie Iskander
 

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

220711130095 Tanu Pandey message currency, communication speed & control EPC ...
220711130095 Tanu Pandey message currency, communication speed & control EPC ...220711130095 Tanu Pandey message currency, communication speed & control EPC ...
220711130095 Tanu Pandey message currency, communication speed & control EPC ...
Kalna College
 
Erasmus + DISSEMINATION ACTIVITIES Croatia
Erasmus + DISSEMINATION ACTIVITIES CroatiaErasmus + DISSEMINATION ACTIVITIES Croatia
Erasmus + DISSEMINATION ACTIVITIES Croatia
whatchangedhowreflec
 
Talking Tech through Compelling Visual Aids
Talking Tech through Compelling Visual AidsTalking Tech through Compelling Visual Aids
Talking Tech through Compelling Visual Aids
MattVassar1
 
Contiguity Of Various Message Forms - Rupam Chandra.pptx
Contiguity Of Various Message Forms - Rupam Chandra.pptxContiguity Of Various Message Forms - Rupam Chandra.pptx
Contiguity Of Various Message Forms - Rupam Chandra.pptx
Kalna College
 
Post init hook in the odoo 17 ERP Module
Post init hook in the  odoo 17 ERP ModulePost init hook in the  odoo 17 ERP Module
Post init hook in the odoo 17 ERP Module
Celine George
 
How to Create a Stage or a Pipeline in Odoo 17 CRM
How to Create a Stage or a Pipeline in Odoo 17 CRMHow to Create a Stage or a Pipeline in Odoo 17 CRM
How to Create a Stage or a Pipeline in Odoo 17 CRM
Celine George
 
Creation or Update of a Mandatory Field is Not Set in Odoo 17
Creation or Update of a Mandatory Field is Not Set in Odoo 17Creation or Update of a Mandatory Field is Not Set in Odoo 17
Creation or Update of a Mandatory Field is Not Set in Odoo 17
Celine George
 
Creativity for Innovation and Speechmaking
Creativity for Innovation and SpeechmakingCreativity for Innovation and Speechmaking
Creativity for Innovation and Speechmaking
MattVassar1
 
BỘ BÀI TẬP TEST THEO UNIT - FORM 2025 - TIẾNG ANH 12 GLOBAL SUCCESS - KÌ 1 (B...
BỘ BÀI TẬP TEST THEO UNIT - FORM 2025 - TIẾNG ANH 12 GLOBAL SUCCESS - KÌ 1 (B...BỘ BÀI TẬP TEST THEO UNIT - FORM 2025 - TIẾNG ANH 12 GLOBAL SUCCESS - KÌ 1 (B...
BỘ BÀI TẬP TEST THEO UNIT - FORM 2025 - TIẾNG ANH 12 GLOBAL SUCCESS - KÌ 1 (B...
Nguyen Thanh Tu Collection
 
Brand Guideline of Bashundhara A4 Paper - 2024
Brand Guideline of Bashundhara A4 Paper - 2024Brand Guideline of Bashundhara A4 Paper - 2024
Brand Guideline of Bashundhara A4 Paper - 2024
khabri85
 
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptxCapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
CapitolTechU
 
bryophytes.pptx bsc botany honours second semester
bryophytes.pptx bsc botany honours  second semesterbryophytes.pptx bsc botany honours  second semester
bryophytes.pptx bsc botany honours second semester
Sarojini38
 
8+8+8 Rule Of Time Management For Better Productivity
8+8+8 Rule Of Time Management For Better Productivity8+8+8 Rule Of Time Management For Better Productivity
8+8+8 Rule Of Time Management For Better Productivity
RuchiRathor2
 
The basics of sentences session 8pptx.pptx
The basics of sentences session 8pptx.pptxThe basics of sentences session 8pptx.pptx
The basics of sentences session 8pptx.pptx
heathfieldcps1
 
INTRODUCTION TO HOSPITALS & AND ITS ORGANIZATION
INTRODUCTION TO HOSPITALS & AND ITS ORGANIZATION INTRODUCTION TO HOSPITALS & AND ITS ORGANIZATION
INTRODUCTION TO HOSPITALS & AND ITS ORGANIZATION
ShwetaGawande8
 
Diversity Quiz Finals by Quiz Club, IIT Kanpur
Diversity Quiz Finals by Quiz Club, IIT KanpurDiversity Quiz Finals by Quiz Club, IIT Kanpur
Diversity Quiz Finals by Quiz Club, IIT Kanpur
Quiz Club IIT Kanpur
 
Cross-Cultural Leadership and Communication
Cross-Cultural Leadership and CommunicationCross-Cultural Leadership and Communication
Cross-Cultural Leadership and Communication
MattVassar1
 
Keynote given on June 24 for MASSP at Grand Traverse City
Keynote given on June 24 for MASSP at Grand Traverse CityKeynote given on June 24 for MASSP at Grand Traverse City
Keynote given on June 24 for MASSP at Grand Traverse City
PJ Caposey
 
Library news letter Kitengesa Uganda June 2024
Library news letter Kitengesa Uganda June 2024Library news letter Kitengesa Uganda June 2024
Library news letter Kitengesa Uganda June 2024
Friends of African Village Libraries
 
(T.L.E.) Agriculture: "Ornamental Plants"
(T.L.E.) Agriculture: "Ornamental Plants"(T.L.E.) Agriculture: "Ornamental Plants"
(T.L.E.) Agriculture: "Ornamental Plants"
MJDuyan
 

Recently uploaded (20)

220711130095 Tanu Pandey message currency, communication speed & control EPC ...
220711130095 Tanu Pandey message currency, communication speed & control EPC ...220711130095 Tanu Pandey message currency, communication speed & control EPC ...
220711130095 Tanu Pandey message currency, communication speed & control EPC ...
 
Erasmus + DISSEMINATION ACTIVITIES Croatia
Erasmus + DISSEMINATION ACTIVITIES CroatiaErasmus + DISSEMINATION ACTIVITIES Croatia
Erasmus + DISSEMINATION ACTIVITIES Croatia
 
Talking Tech through Compelling Visual Aids
Talking Tech through Compelling Visual AidsTalking Tech through Compelling Visual Aids
Talking Tech through Compelling Visual Aids
 
Contiguity Of Various Message Forms - Rupam Chandra.pptx
Contiguity Of Various Message Forms - Rupam Chandra.pptxContiguity Of Various Message Forms - Rupam Chandra.pptx
Contiguity Of Various Message Forms - Rupam Chandra.pptx
 
Post init hook in the odoo 17 ERP Module
Post init hook in the  odoo 17 ERP ModulePost init hook in the  odoo 17 ERP Module
Post init hook in the odoo 17 ERP Module
 
How to Create a Stage or a Pipeline in Odoo 17 CRM
How to Create a Stage or a Pipeline in Odoo 17 CRMHow to Create a Stage or a Pipeline in Odoo 17 CRM
How to Create a Stage or a Pipeline in Odoo 17 CRM
 
Creation or Update of a Mandatory Field is Not Set in Odoo 17
Creation or Update of a Mandatory Field is Not Set in Odoo 17Creation or Update of a Mandatory Field is Not Set in Odoo 17
Creation or Update of a Mandatory Field is Not Set in Odoo 17
 
Creativity for Innovation and Speechmaking
Creativity for Innovation and SpeechmakingCreativity for Innovation and Speechmaking
Creativity for Innovation and Speechmaking
 
BỘ BÀI TẬP TEST THEO UNIT - FORM 2025 - TIẾNG ANH 12 GLOBAL SUCCESS - KÌ 1 (B...
BỘ BÀI TẬP TEST THEO UNIT - FORM 2025 - TIẾNG ANH 12 GLOBAL SUCCESS - KÌ 1 (B...BỘ BÀI TẬP TEST THEO UNIT - FORM 2025 - TIẾNG ANH 12 GLOBAL SUCCESS - KÌ 1 (B...
BỘ BÀI TẬP TEST THEO UNIT - FORM 2025 - TIẾNG ANH 12 GLOBAL SUCCESS - KÌ 1 (B...
 
Brand Guideline of Bashundhara A4 Paper - 2024
Brand Guideline of Bashundhara A4 Paper - 2024Brand Guideline of Bashundhara A4 Paper - 2024
Brand Guideline of Bashundhara A4 Paper - 2024
 
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptxCapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
 
bryophytes.pptx bsc botany honours second semester
bryophytes.pptx bsc botany honours  second semesterbryophytes.pptx bsc botany honours  second semester
bryophytes.pptx bsc botany honours second semester
 
8+8+8 Rule Of Time Management For Better Productivity
8+8+8 Rule Of Time Management For Better Productivity8+8+8 Rule Of Time Management For Better Productivity
8+8+8 Rule Of Time Management For Better Productivity
 
The basics of sentences session 8pptx.pptx
The basics of sentences session 8pptx.pptxThe basics of sentences session 8pptx.pptx
The basics of sentences session 8pptx.pptx
 
INTRODUCTION TO HOSPITALS & AND ITS ORGANIZATION
INTRODUCTION TO HOSPITALS & AND ITS ORGANIZATION INTRODUCTION TO HOSPITALS & AND ITS ORGANIZATION
INTRODUCTION TO HOSPITALS & AND ITS ORGANIZATION
 
Diversity Quiz Finals by Quiz Club, IIT Kanpur
Diversity Quiz Finals by Quiz Club, IIT KanpurDiversity Quiz Finals by Quiz Club, IIT Kanpur
Diversity Quiz Finals by Quiz Club, IIT Kanpur
 
Cross-Cultural Leadership and Communication
Cross-Cultural Leadership and CommunicationCross-Cultural Leadership and Communication
Cross-Cultural Leadership and Communication
 
Keynote given on June 24 for MASSP at Grand Traverse City
Keynote given on June 24 for MASSP at Grand Traverse CityKeynote given on June 24 for MASSP at Grand Traverse City
Keynote given on June 24 for MASSP at Grand Traverse City
 
Library news letter Kitengesa Uganda June 2024
Library news letter Kitengesa Uganda June 2024Library news letter Kitengesa Uganda June 2024
Library news letter Kitengesa Uganda June 2024
 
(T.L.E.) Agriculture: "Ornamental Plants"
(T.L.E.) Agriculture: "Ornamental Plants"(T.L.E.) Agriculture: "Ornamental Plants"
(T.L.E.) Agriculture: "Ornamental Plants"
 

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.
  翻译: