Thursday, June 11, 2009

How to make Content Web Pages to use existing Master Page

Let us say you want to add a new page Page1.aspx to use Site.Master…  Lets say that Site.Master already exists in your project…

If you were to add Page1.aspx as a simple .aspx page then you will have to make manual change to the <%@ Page directive of the page to make sure Inherits property is set correctly… But generally you will not need to do this if you add the file in the below fashion…

WEB SITE PROJECTS: If you are using a Web Site Project (i.e. below)

new web site

Then in that case you can Right click on your project –> Add New Item and “Select Master Page”

new web form

On the next page you will get an option to select the master page as shown below:

Web Site Master

WEB APPLICATION PROJECTS (WAPs):   If  you are using a WAP (i.e. File –> New Project as shown below)

new WAP

Then while adding a new page, right click on your project—> Add –> New Item and instead of selecting “Web Form” select “Web Content Form” as shown below:

web content form

When you now click the “Add” button you will get to select the Site.Master page that you had previously added to your project… Check the figure below…

web form site master

Hope this helps…

- Vishal | Twitter: @VishalRJoshi |

No comments: