Oscar Cabrero Oscar Cabrero - 11 days ago 7
C# Question

How to add the namespace automatically on every new Page, Control added To a WebSite in VS2008?

How do you add the namespace automatically on every new Page, Control added To a website in VS2008?

When I add a new page, the code behind looks like this.

public partial class MyNewPage : System.Web.UI.Page
{

}


I just want the page wrapped into a namespace as below:

namespace Project.Web
{

public partial class MyNewPage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e){}
}

}


This is done automatically when you have a website project.

Maybe it's trivial but I haven't find out how to do this.

Answer

Put the namespace under "Default Namespace" in project properties, and it doesn't need to be in the code files.