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): - Copy the "HTMLPage" directory (as listed above) to an "HTMLExamplePage" directory in the same folder.
- This directory should have 2 subdirectories. One called "Templates" and one called "Scripts."
- 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.
- Move to the "Scripts1033" subdirectory and there will be a "default.js" javascript file.
- Edit this file. On line 11, change "HTMLPage.htm" to whatever you called your template file
- Now we need to move up to the "Vb7VbProjectItems" directory (in Microsoft Visual Studio.NET).
- File copy "HTMLPage.vsz" to "HTMLExamplePage.vsz." Edit the file by changing "Param="WIZARD_NAME= HTMLPage" to "Param="WIZARD_NAME = HTMLExamplePage"
- Still in the "VbProjectItems" directory, go to the "Web Project Items" subdirectory.
- Open the "WebProjectItems.vsdir" file (Notepad or VS.NET will open it).
- 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 - Duplicate this entry in the WebProjectItems.vsdir file (I just copied it right below the original).
- 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 - 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.
- 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.
- 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. |
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |
More ASP Code Articles More By aspfree developerWorks - FREE Tools! | Join this webcast, to learn how the Rational Process Library can help with compliance issues, drive process improvement, and assist in service-oriented architecture (SOA) or Agile development. We will take a peek into the Rational Process Library with content around software and systems engineering (including RUP), operations and systems management, program and portfolio management, and asset and SOA governance. FREE! Go There Now!
| | | | Learn how you can extend modern application lifecycle management to IBM System z through the IBM Rational Software Delivery Platform (SDP). The Did you say mainframe? e-kit includes podcasts, webcasts, tutorials, white and red papers, demos, and articles designed to help ease the challenges of modernizing your enterprise. This complimentary kit for mainframe developers is a practical, how-to guide for making the most of an existing development environment, including the skills and infrastructure already in place at an established enterprise. FREE! Go There Now!
| | | | Discover how IBM Rational AppScan Standard Edition can help you detext vulnerabilities in your web applications in the Web Application Security eKit. IBM Rational AppScan is a leading suite of automated web application security solutions that scan and test for common Web application vulnerabilities. The new Web Application Security eKit provides you with valuable resources, including white papers, demos, and additional information on the benefits of testing your Web applications. FREE! Go There Now!
| | | | Download a free trial version of IBM Rational Developer for System i V7.1, which provides a complete development environment for traditional i5/OS application development. IBM Rational Developer for System i is a new eclipse-based workstation offering for i5/OS application development that provides a comprehensive Integrated Development Environment for edit/compile/debug of traditional RPG/COBOL/C/C++ i5/OS applications. FREE! Go There Now!
| | | | Learn how to do more with your reusable assets with the free Rational Asset Manager eKit. The eKit includes demos on how Rational Asset Manager tracks and audits your assets in order to utilize them for reuse. Plus you’ll find white papers and a Webcast that discuss the challenges of a Service Oriented Architecture and how Rational Asset Manager can provide quick and effective solutions. FREE! Go There Now!
| | | | Discover how Rational tools and best practices for testing can make your job easier. The new Rational Testing eKits provide you with valuable resources – including demos, webcasts, tutorials, and articles – that help you address your specific testing needs across the software lifecycle. Five new eKits are available covering the topics of Requirements and Test Management, Functional Testing, Performance Testing, Code Quality and Embedded Systems, and SOA and Web Services Testing. FREE! Go There Now!
| | | | As organizations have grown increasingly dependent on online software, the risk of malicious attacks has also become far more serious. Fortunately, well-governed organizations can protect their Web applications by injecting vulnerability assessments and ethical hacks into their software development and delivery processes. This paper describes 12 of the most common hacker attacks and provides basic rules that you can follow to help create more hack-resistant Web applications. FREE! Go There Now!
| | | | Get a free trial download of IBM Lotus Forms V3.0 (formerly Workplace Forms), which provides a zero-footprint eForms solution to help you automate and move forms-based business processes off the desktop and onto the Web. With Lotus Forms, you can extend applications beyond the firewall by creating a single electronic form document ready for use in both thick and Web 2.0 thin client format. FREE! Go There Now!
| | | | Viper 2 brings a great value to developer communities including SQL, XML, PHP, Ruby, .NET and Java. You probably already know that DB2 Express-C is free for developers to develop, deploy and distribute. Viper 2 provides a variety of means that help move your application from the development stage to deployment more rapidly. This webcast shows how to best utilize the latest tools available for developing DB2 applications. FREE! Go There Now!
| | | | Explore how Rational and WebSphere software enable enterprise documentation in SOA environments. Specifically, a new integration between IBM WebSphere® Business Modeler and IBM Rational® Method Composer software can help technical writers more easily keep enterprise operations manuals in sync with changes that are made to business processes, resulting in more accurate and timely documentation that benefits the entire enterprise. FREE! Go There Now!
| | | | All FREE IBM® developerWorks Tools! | |