Search code examples
c#visual-studio-2013referenceusing-directivesvisual-studio-templates

Set default namespace include references for Web Form with Master template?


I would like to modify the default using statements included at the top of the code behind file of a newly created web form (with master page) in Visual Studio 2013. My application is a C# Web Application.

Currently, when I use the template for "Web Form with Master Page" to create a new page, it will use the following using references:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

I would like to modify the list that appears for this template, or copy the template and give it a new name and include the new list.

If the template change is project specific, I would just change this template. If the template change is IDE wide, I'd like to copy the web form with master template and include the modified list in the copy.

Is there a way to do this?

I followed these steps according to the directions provided by jonathan twite.

  1. Created a page from the default web form with master page template.
  2. Added the using statements and saved.
  3. Exported that form using File > Export Template
  4. I then added a new page using that template by right-clicking on project > Add > New Item > Visual C#
  5. The template is listed there for me, I chose it and then typed in the new name and the using statements were in the new file.

Thank you,


Solution

  • I think you may want to make a template:

    https://msdn.microsoft.com/en-us/library/xkh1wxd8(v=vs.120).aspx

    Use "Export Template..." from the File menu to create a template from your current project