Introduction
What is Master Page ?
Master pages are one of my favorite features within .NET. By design, they provide a single location for common layouts that are used across a set of web pages and allow common updates to occur in one place.
You will see in most of the website every page has the same content at the top and bottom of the page. In this place, we can use the master page.
So, What is nested master page?
It's A child master page of a master page and has its own content placeholders of its own to display content supplied by its own child pages.
When will we use it? Sometimes we need to create a web application where all the pages have the same header and footer but a different structure in the main content area.
Like : - | |
|
|
One Column Main content Area | Two Column Main content Area |
Here I am going to design 2 web pages where both contain same Header and footer but different structure in main content area
Where are the steps for this...
Steps :
Just follow the steps and get result easily.Step - 1 : Create New Project
Go to File > New > Project > Select asp.net web forms application > Entry Application Name > Click OK.Step-2: Add a Master Page.
Go to Solution Explorer > Right Click on Project under solution explorer > Add > New item > Select Master Page under web> Enter Name > Add.Here I have named MasterCommon.Master
Step-3: Design your master page (For One Column Pages).
Here we will design Header and Footer section mainly.Step-4: Add 1st Web Page (For One Column Web Page).
Go to Solution Explorer > Right Click on Project under solution explorer > Add > New item > Select Web Form using Master Page under web > Enter Name > > Select Master Page (Here Select MasterCommon.Master)>Add.Design your web page as Single column web page
Step-5: Add a Nested Master Page (For Two Columns Pages).
Go to Solution Explorer > Right Click on Project under solution explorer > Add > New item > Select Nested Master Page under web> Enter Name > Select Master Page > Add.Here I have named NestedMasterPage1.Master
Here we will add 2 ContentPlaceHolder as I have already said Nested Master Page has its own ContentPlaceHolder.
Step-6: Add 2nd Web Page (For Two Column Web Page).
Go to Solution Explorer > Right Click on Project under solution explorer > Add > New item > Select Web Form using Master Page under web > Enter Name > > Select Master Page (Here Select NestedMasterPage1.Master)> Add.Design your web page as Double column web page
Step-7: Run Application.
Thank YouDownload Source Code.