Total Page Preview:   000000001191

What is master pages in ASP.NET in English and Hindi

 

 

 

Masterpage in ASP.NET in English:

In ASP.NET a Master Page is a template that defines the common structure, layout, and user interface elements for a website. A Master Page can contain static content, server controls, and other dynamic content that is shared across multiple pages in the website .

Using a master page can also simplify the process of making changes to the layout of an application. If a change is needed, it can be made to the master page, and that change will be reflected across all pages that use that master page.

MasterPage is a template that allows you to define a consistent look and feel for your web application. You can use a MasterPage to define the layout and structure of your website, including things like the header, footer, and navigation menu Or in other words you also can say a master page is a template for creating consistent layouts for multiple web pages in an ASP.NET web application. It contains the common elements of the web pages, such as the header, footer, navigation menus, and other layout elements.

 
Here's an example of how to create a MasterPage in ASP.NET with C#:
 
1-Create a new ASP.NET Web Application project in Visual Studio.
 
2-Right-click on the project in the Solution Explorer and select "Add New Item."
 
3-Choose "Master Page" from the list of templates and give it a name (e.g., Site.master).
 
4-In the MasterPage file, you can define the layout and structure of your website.
 
For example, you might include HTML and CSS to define a header and footer:
 
 
 
 
5-In your web pages, you can then reference the MasterPage by adding a "MasterPageFile" attribute to the @Page directive at the top of the file:
 
 
 
In this example, the "MainContent" placeholder in the MasterPage is replaced with the content of the web page. When the web page is rendered, the MasterPage is used to provide the overall layout and structure, while the content of the page is inserted into the appropriate placeholder.
 
 
 
 
Masterpage in ASP.NET in Hindi:
 
Master Page ek aisi template hoti hai jisey use karke hum multiple web pages ke consistent layouts bana sakte hai, jaise header, footer, navigation menus, etc. Master Page ka use karke hum ek hi layout ko multiple pages mai use kar sakte hai, jisse humare web application ka look and feel consistent rahta hai.
 
Ek simple example ke through samajhte hai, maan lijiye ki hum ek ecommerce website bana rahe hai jisme humare website ke sabhi pages mai ek hi header, footer, aur navigation menu hona chahiye. Is scenario mai hum Master Page ka use kar sakte hai.
 
Sabse pehle hum Master Page ko create karte hai aur usme header, footer, aur navigation menu ko add karte hai. Ab hum web pages ko create karenge aur unhe Master Page se inherit karenge. Inherited pages mai sirf content ko add karna hota hai aur Master Page ke layout mai changes karne ki jarurat nahi padti hai.
 
Overall, Master Page ka use karke hum web application ke pages ke design aur layout ko easily maintain kar sakte hai aur sath hi sath time bhi save kar sakte hai.
Ek aur Example samjte hai agar ek website ka header, footer aur navigation menu saare pages mein same hona chahiye, lekin content alag-alag hona chahiye, to master page ka use kiya ja sakta hai. Master page mein header, footer aur navigation menu hote hain, aur Masterpage mein sirf unique content hota hai. Is se saare pages mein ek consistent layout maintain hota hai, jabki content alag-alag hota hai.
 
niche diye gaye code snippet me, ek Master page ka example hai jo ek navigation menu aur ek header bar define karta hai:
 
 
content page me, Master page ka use karte hue, MasterPageFile attribute ka use kiya jata hai:
 
 
Isme, ContentPlaceHolder control MainContent ID ke sath Master page ke ContentPlaceHolder control ke sath match karta hai. Jab content page run hoti hai toh, Master page ke elements ke sath iska content add ho jata hai.
 
 
 
 
 
 
 

Thank You

About Author

Brijesh Kumar

Database Developer

I have more then 6 years Experience in Microsoft Technologies - SQL Server Database, ETL Azure Cloud - Azure SQL Database, CosmosDB, Azure Data Factory, PowerBI, Web Job, Azure Function, Azure Storage, Web Apps, Powershall and Database Migration On-Premise to Azure Cloud.
LinkedIn : https://www.linkedin.com



Comments


                           
                           

                           

                           

Facebook User: