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! | Hold your calendar on January 30, 2008 for this free webcast on the new i5/OS. Rational's Enterprise Modernization products will be discussed at this webcast as they help to drive the application development environment for this new System i OS. <br />And learn how i5/OS will take you to the next step of efficient, resilient business processing. You will hear about the new i5/OS capabilities as it will be the most significant i5/OS release in years. If you cannot join the webcast on 1/30/08 you can still use this link to listen to the replay.<br /> FREE! Go There Now!
| | | | You probably have thousands of lines of COBOL code loaded with business intelligence and being used to run your business, along with an army of developers maintaining these applications. Learn how to prepare your applications and developers so you can keep that competitive edge and move to a service-oriented architecture with the IBM Rational Enterprise Modernization solutions. Replay is available for 9 months. FREE! Go There Now!
| | | | WebSphere Process Server delivers a unique integration framework that simplifies existing IT resources. Often, as IT assets grow to support business demand, so too does their complexity and manageability. In this webcast, we’ll discuss how WebSphere Process Server helps deliver an SOA infrastructure that provides a common model to orchestrate, mediate, connect, map, and execute the underlying IT functions. Discover how WebSphere Process Server simplifies integration of business processes by leveraging existing IT assets as reusable services without the complexities of traditional integration methodologies. FREE! Go There Now!
| | | | This tutorial shows new users of IBM WebSphere Business Monitor Version 6.0.2 how to perform the "Hello World" equivalent for monitoring business process applications. It is intended to help you get familiar with the capabilities of the product. FREE! Go There Now!
| | | | Analysts, architects, and developers who have existing COBOL or PL/I skills and want to extend those skills to deploy new workloads on the mainframe can use the IBM Enterprise Modernization Sandbox for System z to find hands-on walkthroughs of common real world scenarios. The scenarios provide examples of how to rapidly design, create, assemble, test, and deploy high-quality Web, Web services, portal, and SOA applications for IBM CICS, IBM IMS, and IBM WebSphere Application Server. FREE! Go There Now!
| | | | Rational Modeling Extension for Microsoft .NET enhances usability for code generation supporting a more intelligent refactoring. The latest enhancements enable organizations with Java and .NET systems and software development maintain architectural integrity across heterogeneous platforms. FREE! Go There Now!
| | | | Attend this launch webcast with Scott Hebner, Vice President of IBM Rational Marketing and Strategy, where he will overview Rational’s new offerings and programs to help customers accelerate software innovation on System z. He will discuss how these solutions help organizations extend their core business processes toward modern architectures such as SOA and web technologies to deliver business improvements that stand the test of time. FREE! Go There Now!
| | | | In this webcast, IBM Rational will discuss the importance of Web application security and will share techniques and best practices to introduce application security testing into current QA processes including: understanding common security vulnerabilities and techniques to integrate security testing with defect tracking and remediation systems in an effort to safeguard sensitive online information. FREE! Go There Now!
| | | | The Eclipse community is constantly working to extend Eclipse's functionality. In this webcast, learn about some of the most important and feature-rich projects under development. From multi-language support to plug-in development, tune in to see what Eclipse is capable of now. FREE! Go There Now!
| | | | The discipline of assembling and delivering software is maturing beyond standard developer-centric compile/test software builds. The end-to-end software development lifecycle is emerging as the new focus moves “Beyond the Build.” Join this on demand webcast to learn about methods for streamlining software delivery and key capabilities of the IBM Rational Build Forge framework for automating build and release management in environments of any size. FREE! Go There Now!
| | | | All FREE IBM® developerWorks Tools! | |