Click here to Skip to main content
13,770,032 members
Click here to Skip to main content
Add your own
alternative version


39 bookmarked
Posted 28 May 2004

Add a custom template to Visual Studio .NET 2003

, 28 May 2004
Rate this:
Please Sign up or sign in to vote.
An article that explains a method to add your own custom template in the Visual Studio .NET 2003 IDE.

Sample Image


I have always wondered if there is a way to change or rather remove the default contents of the 'New Item' presented by VS.NET 2003 IDE, when I create a new file for my Microsoft .NET project. I knew that it should be somehow possible to do it, but will it take me to install a new plug-in or make more of Google to do it.

I tried to check some sources for this purpose and resulted myself in experimenting with the information in the Visual Studio .NET 2003 Help Documentation. All the information given here are from my understanding on the information present in the Visual Studio .NET 2003 Help Documentation.

Note: the attached files are just sample files and are not source files as you may find in other articles.

Background for the article

This article's contents are written after I went through the contents in Visual Studio .NET 2003 Help Documentation.

Template Creation Process

As an ASP.NET developer, for this article, I would be focusing on the template for 'WebForm' using Visual Basic .NET.

I hereby assume that the visitor to this article would have a good idea on how to create and use a Project using Visual Basic .NET in Visual Studio .NET 2003 IDE. You can create a new WebForm for your web project from the Visual Studio .NET 2003 by:

File --> Add --> Add New Item (select the ‘WebForm’ there)

The default 'aspx' page generated by Visual Studio .NET 2003 would be as follows:

<%@ Page Language="vb" AutoEventWireup="false" 

    Codebehind="WebForm2.aspx.vb" Inherits="TestWeb.WebForm2"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
    <meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
    <meta name=vs_defaultClientScript content="JavaScript">
    <meta name=vs_targetSchema 

  <body MS_POSITIONING="GridLayout">

    <form id="Form1" method="post" runat="server">


I wanted the above code to be generated as follows:

<%@ Page Language="vb" AutoEventWireup="false" 

  Codebehind="TemplateWebForm2.aspx.vb" Inherits="TestWeb.TemplateWebForm2"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
        <title>My Template</title>
        <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
        <meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
        <meta name="vs_defaultClientScript" content="JavaScript">
        <meta name="vs_targetSchema" 

        <meta name="Author" content="Saravana Kumar S P">
        <meta name="Author Mail" content="">
    All sorts of stuffs that I want to put here
        <form id="Form1" method="post" runat="server">

There are two ways to play around with this.

  1. Replace the template - change the default content of the WebForm from Visual Studio .NET 2003’s content to the required format.
  2. Create a new template - create with the different content for the WebForm, and allow it to be selected from the screen, when creating a ‘New Item’.

We will see both of them in this article. Although I am most interested in the second option.

Option 1: Replace the template.

This is as good as a piece of a cake.

  1. Open the following directory:
    C:\Program Files\Microsoft Visual Studio .NET 2003\
  2. The above folder is self explanatory. It is in the Visual Studio .NET 2003 installation folder, and I have chosen the WebForm in the VBWizards, that is in the VB language folder for VS .NET 2003. In this folder, we have one file WebForm.aspx.
  3. This is the template file we are talking about. Now, open the file and modify the contents and save it back.
  4. Yes, we got the job done.
  5. Now, open a Web Project in VB.NET, in your Visual Studio .NET 2003 IDE.
  6. Create a new WebForm for the project. Here, you will get the contents from the file you had just edited.

Option 2: Create a new template.

Note: sample files in this article correspond to this method.

This is something I was looking for days, and oops, finally got it from the Visual Studio .NET 2003 Help Documentation. To do this, close the Visual Studio .NET 2003 IDE and follow these steps in the given order:

  1. Locate the following folder:
    C:\Program Files\Microsoft Visual Studio .NET 2003\Vb7\VBWizards
  2. Copy the folder WebForm into a new name as TemplateWebForm.
  3. Now locate this new path:
    C:\Program Files\Microsoft Visual Studio .NET 2003\
  4. Rename the file WebForm.aspx to TemplateWebForm.aspx.
  5. This file is going to be the new template. So, change the contents of this file TemplateWebForm.aspx. You can come back and change the contents later too.
  6. Locate the file default.js in one of the new folders created just now:
    C:\Program Files\Microsoft Visual Studio .NET 2003\
  7. In line #16, change the “WebForm.aspx” to “TemplateWebForm.aspx”.
  8. Save and close the file, you may not need to edit this file anymore.
  9. Now go to this folder:
    C:\Program Files\Microsoft Visual Studio .NET 2003\Vb7\VBProjectItems
  10. Copy the file WebForm.vsz as a new file and name it as TemplateWebForm.vsz.
  11. In line #3, change the WebForm to TemplateWebForm.
  12. Save and close the file.
  13. Go in to the directory Web Project Items and create a new file and name it as UserProjectItems.vsdir (you will have to maintain the extension of the file as it is given above).
  14. Put the following line of code there:
      My Template|10|A user-created web form for CP|
  15. Now, fire up the Visual Studio .NET 2003 IDE, and open / create your web project.
  16. Add a NEW ITEM, and the link for the template is listed there as ‘My Template’.
  17. Select it and play around with it.

To Do’s for this article:

  1. The template is listed in the top level root of ‘Web Project Items’ only. This can also be made available in the respective folders also – ‘UI’ in this case.
  2. Show the ‘Add My Template’ in the menu ‘Add’, that appears when you right click the Web Project in the Solution explorer.


To be updated whenever I find that I have something new to be told about this article!


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Sarvesvara (BVKS) Dasa
Team Leader Emirates Group IT (Emirates Airline)
United Arab Emirates United Arab Emirates
No Biography provided

You may also be interested in...

Comments and Discussions

Generalnice Pin
Pranay Rana23-Dec-10 2:01
professionalPranay Rana23-Dec-10 2:01 
QuestionUsing a web html template in asp? Pin
Tarun.Suneja24-Sep-08 8:24
memberTarun.Suneja24-Sep-08 8:24 
QuestionIn VS 2005, how do you change the template used when a master page is selected? Pin
jsneeringer27-May-07 17:02
memberjsneeringer27-May-07 17:02 
GeneralChange Icon Pin
rramirezc29-Apr-05 23:15
sussrramirezc29-Apr-05 23:15 
GeneralChange Icon Pin
gchmex29-Apr-05 23:12
membergchmex29-Apr-05 23:12 
Generalneed details, plz Pin
Andriy Ivanov3-Mar-05 8:21
memberAndriy Ivanov3-Mar-05 8:21 
GeneralGreat!, and also Pin
Philip Fitzsimons2-Jun-04 1:45
memberPhilip Fitzsimons2-Jun-04 1:45 
GeneralRe: Great!, and also Pin
Sarvesvara (BVKS) Dasa2-Jun-04 5:28
memberSarvesvara (BVKS) Dasa2-Jun-04 5:28 
GeneralRe: Great!, and also Pin
barsju15-Jul-04 23:38
memberbarsju15-Jul-04 23:38 
GeneralRe: Great!, and also Pin
Sarvesvara (BVKS) Dasa16-Jul-04 0:59
memberSarvesvara (BVKS) Dasa16-Jul-04 0:59 
GeneralRe: Great!, and also Pin
Jeremy Rosenberg30-Sep-04 10:56
memberJeremy Rosenberg30-Sep-04 10:56 
GeneralRe: Great!, and also Pin
Ashley van Gerven10-Nov-04 19:00
memberAshley van Gerven10-Nov-04 19:00 
GeneralGood one! Pin
Prakash Nadar30-May-04 7:20
memberPrakash Nadar30-May-04 7:20 
GeneralRe: Good one! Pin
Sarvesvara (BVKS) Dasa2-Jun-04 5:23
memberSarvesvara (BVKS) Dasa2-Jun-04 5:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web06-2016 | 2.8.181119.1 | Last Updated 29 May 2004
Article Copyright 2004 by Sarvesvara (BVKS) Dasa
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid