.NET Developments

Mar 7 2008   3:00PM GMT

Using Master Pages in Visual Studio 2008

Brein Matturro Profile: Brein Matturro

The way you use Master pages has changed in Visual Studio 2008.  Remember, how in Visual Studio 2005 when you add a new Web Form in ASP.NET applications – you get to choose a master page to apply to the Web form.  If you choose to use a Master page – then the page that is added, when you check the HTML code for that page – it is stripped of all the standard HTML tags – only the Page directive and the <asp:Content> tags are available.  This is a Content page.

In Visual Studio there are two types of Web Forms available – Web Form and the Web Content Form

The Web Form is a standard Web Form – without the Master page, with its HTML code like a standard HTML page.  Whereas, the Web Content Form is the one to which you can attach a Master page.

The Web Form page also has a MasterPageFile property.  But, if you create a Web Form and then set the MasterPageFile property to link to your Master page you will get a run time error.

Content controls have to be top-level controls in a content page or a nested master page that references a master page.

This is because content pages must not have another other HTML tags or controls. 

If you want to use Master Pages use Web Content Form, otherwise use the Web Form.

Another nice feature in Visual Studio 2008 – is that in that in the top right corner of the Design window of the Web content page is a link to the Master page that this page is linked to.  Also, the “Split” view is cool.. you can now see the source and the design view tiled in the design area.

4  Comments on this Post

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.
  • CoolScraps.info !! More Bollywood Music Scraps !! Preety
    This is very interesting and useful to know, coz from last few days I was struggling with this concept as I was trying to do it in the way I used to in .net 2005. Great blog
    0 pointsBadges:
  • D. Ross
    Trust me, everyone is very appreciative of this information. I was struggling and fustrated because I was not being able to use a masterpage with the web form. I am new to Visual Studio 2008 but I am learning. Again, thank you please publish whatever you think would be helpful when it comes to Visual Studio 2008 please.
    0 pointsBadges:
  • Alwaysme
    You saved my life. Thanks once again for the post.
    0 pointsBadges:
  • Gksrivastava
    thanks so muck ..it was mystery for me...but u solve it very easily...thanks again
    0 pointsBadges:

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

Share this item with your network: