Saturday, July 23, 2011

.NET and ASP.NET interview questions: - How to create a simple “Master Page” in ASP.NET?

Master Page: - Master pages let you make a consistent layout for your application, you can make one master page that holds the layout/look & feel and common functionality for your whole application and upon this master page, you can build all the other pages, we call these pages Content Pages. So simply you can build your master page and then build content pages, and while creating the content pages you bind them to the master page you have created before, those two pages are merged at runtime to give you the rendered page.
Let’s see a practical demonstration how exactly we can create “Master Page” in your application.

In order to create a simple “Master page” you need to follow the following steps.

Step 1: - Create a new project > select ASP.NET Empty Web Application.



Step 2: - Right click on the project > select Add >Add new item > select “Master Page” and click Add.



As soon as you click on Add a new file will be created with .master extension like below diagram.



Step 3: - Now just place the content’s you want to keep constant in our application.



Step 4: - just follow the below diagrams to add forms to our application.

Right click on the project > select Add >Add new item > select “Web Form using Master Page” and click Add.



As soon as you click on add, a new window will appear like below diagram from that select your “master page name” and click ok.



Similarly, if you want to add more pages in our application just follow the Step 4.

Once you have done with above steps, now you can run our application and see the output with master page.

View the following video on Single sign-on using forms authentication in ASP.NET



View more .NET and ASP.NET interview questions

Regards,

View more authors learning tutorials on .NET and ASP.NET interview questions

No comments: