Using a Master Page in ASP.net

by Sumant 17. June 2007 10:51

The easiest & quickest way to get on with Master Pages

Creating a Master Page :

  1. Create an aspx page, as you want the basic layout to be.
  2. Add a new Master Page to your web app.
  3. Copy all code from aspx page created in step 1, exclude @Page tag
  4. Paste everything by replacing default code in MasterPage, keep @Page tag as it is
  5. Wherever you want content to appear from content pages, place a <asp:contentplaceholder> control
  6. Master page is ready now

The above method helps in previewing changes easily, though a master page can be created directly without using an aspx page first, and can be previewed using a content page.


Using a Master Page :

  1. Add a WebContentForm to web app.

    {if its a web project, you will have to select WebForm and check 'select master page' check box while adding this page.}
  2. Select the master page for this page. That's it!

    {If a page already exist and you want to convert it to a content page, add "MasterPageFile" attribute in @Page directive of the wannabe content page and remove all html code from this page and pace <asp:content> control and the code you want to appear in content area.}

 

Share   
Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

Tags:

.NET | ASP.NET | Web Development

© 2008 Sumant Dubey

About this blog

Absolutely technical! The posts are about concepts, tricks, articles and links on technical subjects / problems which are not very obvious to understand / resolve. Purpose is to have this as the first-aid in the time of need.

Disclaimer

The opinions expressed on this website are my own personal opinions and do not represent my employer's view in anyway.