Add Your Own HTML template to the

Contributed by
Rating: 5 stars5 stars5 stars5 stars5 stars / 27
November 17, 2001
Rate this Article:
MEH MEH++


SEARCH ASP FREE
TOOLS YOU CAN USE

advertisement

Add Your Own HTML template to the "Add New Items"
list in VS.NET by Curtis Swartzentruber

If you are like me, you tend to just jump into the Visual Studio IDE and get to work. However, there is a lot of customization you can do to improve your productivity. For example, large project teams can use Enterprise Templates to enforce coding standards, layouts, and guidelines across a project or organization.

I just wanted to do something simple though. When you are working in Visual Studio, you can use the "Add New Item" functionality to add a file of a certain type to your project, such as a blank HTML page, aspx page, or vb class file. No big news there. When adding an HTML page, I wanted the option of using my own template rather than the default. There are basically 2 ways to do this, change the default template VS.NET uses or create your own template.

The templates that VS.NET uses for VB.NET are located in your "Microsoft Visual Studio.NET" directory, typically in "Program Files." on whatever drive you installed VS.NET on. Go to:

{x]:Program FilesMicrosoft Visual Studio.NETVb7VBWizardsHTMLPageTemplates1033HTMLPage.htm

and just change that to include whatever you want. Obviously you can do this with the other templates in that directory as well. I'm just focusing on the HTML template.

To add an additional template, here are the steps I used (please change HTMLExamplePage to whatever you like):

  1. Copy the "HTMLPage" directory (as listed above) to an "HTMLExamplePage" directory in the same folder.
  2. This directory should have 2 subdirectories. One called "Templates" and one called "Scripts."
  3. Rename the template file in the copied "HTMLExamplePageTemplates1033" directory to "HTMLExamplePage.htm" or whatever you want. I don't think you necessarily have to change the name of the template file, although it probably makes the most sense. Edit the file to include whatever HTML you want your template to have.
  4. Move to the "Scripts1033" subdirectory and there will be a "default.js" javascript file.
  5. Edit this file. On line 11, change "HTMLPage.htm" to whatever you called your template file
  6. Now we need to move up to the "Vb7VbProjectItems" directory (in Microsoft Visual Studio.NET).
  7. File copy "HTMLPage.vsz" to "HTMLExamplePage.vsz." Edit the file by changing "Param="WIZARD_NAME= HTMLPage" to "Param="WIZARD_NAME = HTMLExamplePage"
  8. Still in the "VbProjectItems" directory, go to the "Web Project Items" subdirectory.
  9. Open the "WebProjectItems.vsdir" file (Notepad or VS.NET will open it).
  10. This file tells VS.NET how to show all the "Add New Item" items. Scan down through the file to the following line:

    ..HTMLPage.vsz|{164B10B9-B200-11D0-8C61-00A0C91E29D5}| #3070 |70|#3071|{164B10B9-B200-11D0-8C61-00A0C91E29D5}|4537| |HTMLPage.htm
  11. Duplicate this entry in the WebProjectItems.vsdir file (I just copied it right below the original).
  12. Change it to reference your new template.

    ..HTMLExamplePage.vsz|{164B10B9-B200-11D0-8C61-00A0C91E29D5}|Example Page|70|#3071|{164B10B9-B200-11D0-8C61-00A0C91E29D5}|4537| |HTMLExamplePage.htm
  13. If you want to know more about vsz or vsdir files, please see the VS.NET help. These steps may not work with all file types, but they do work with HTML templates. I would expect they will work with aspx templates as well, although I haven't tested that yet.
  14. You will notice I also changed #3070 to Example Page. This entry controls what shows up in the "Add New Item" dialog box so you can differentiate your template from the normal "HTML Page" template.
  15. Restart VS.NET and open a Web application. When you do "Add New Item," your template should now be in the list.

You can do a whole lot of things with templates in VS.NET, although my knowledge at this point is limited. This is barely scratching the surface. However, I had to dig around a bit to figure this out, so I thought I would share this info.

blog comments powered by Disqus
ASP CODE ARTICLES

- ASP Forms
- ASP: The Beginning
- Getting Remote Files With ASP Continued
- Inbox and Outbox Manipulation in ASP
- Relational DropDownList Using VB.NET
- Ad Tracking URL Hits
- Use ViewState to display one record per page...
- Send Email using ASP.NET formatted in HTML
- ASP File Explorer
- ASP/XML Interview questions by Srivatsan Sri...
- Pressing RETURN won't submit the form
- This shows how you get the TEXT of a combo r...
- Group Data by Adrian Forbes
- Multiple checkbox select sample
- Multiple checkbox select with all values sam...

ASP Web Hosting ASP.Net Web Hosting Windows Web Hosting
 
 
 

ASP Free Forums 
 RSS  Tutorials RSS
 RSS  Forums RSS
 RSS  All Feeds
Site Map 
Request Media Kit
Write For Us Get Paid 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Privacy Policy 
Support 


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 8 - Follow our Sitemap
Most Popular Topics
All ASP.Net Tutorials