customize the template of new files in vs.net 2003

类别:.NET开发 点击:0 评论:0 推荐:

In VS.net 2003, when we add a new item, i.e. a class, a webpage, or a form, to the project, the IDE will automatically generate some code in the newly-created files. This can surely save us some time writing repeated code. But sometimes we may want to customize the auto-generated code, for instance to add the copyright info in the header of the files. Although undocumented, there is a way to customize the templates from which vs.net 2003 created new files.
First let's take a look into the vs.net 2003 installation folder, as illustrated in the following figure:

We'll examine VC# folder only here, other folders (such as Vb7 and Vc7) are simlimar in structure. As can be seen, there is a “VC#Wizards” folder under “VC#”. This folder stores all the templates from which all the new files are created. Folder “VC#Wizards\1033” is the deposit for shared files common to all the templates, such as javascript, cascade style sheet, and images. “1033” stands for “US-English” culture. This number should vary according to your vs.net 2003 installation language. Except this shared folder, each folder under “VC#Wizards” represents one kind of template and has a “Templates\1033” subfolder in it. Again, “1033” have the same meaning with that under “VC#Wizards”.
For example, if we create a asp.net web application, the template for web form resides in “VC#Wizards\CShareWebAppWiz\Templates\1033”and is named "WebForm1.aspx", as shown in the following figure:

Now we can customize the content of this file as we need. We can also make modification to other templates in the same way.

Please Note: The templates specified in this article have effect to all the users sharing the same computer and developing using vs.net 2003, so make sure your modification is what is really needed by everyone. Besides, vs.net 2003 is fully customizable, if you like, you can also choose to use vb macros to add some content to your code, which is especially useful for adding some universal comments (such as copyright info) whenever a new file is created.

本文地址:http://com.8s8s.com/it/it42790.htm