Microsoft KB Archive/323843

= HOW TO: Add a CSS Style Sheet Reference to All Web Forms in a Visual Basic .NET Web Project =

Article ID: 323843

Article Last Modified on 6/12/2003

-

APPLIES TO


 * Microsoft ASP.NET 1.0
 * Microsoft Visual Basic .NET 2002 Standard Edition
 * Microsoft Visual Studio .NET 2002 Professional Edition
 * Microsoft Visual Studio .NET 2002 Enterprise Architect
 * Microsoft Visual Studio .NET 2002 Enterprise Developer
 * Microsoft Visual Studio .NET 2002 Academic Edition
 * Microsoft ASP.NET 1.1
 * Microsoft Visual Basic .NET 2003 Standard Edition
 * Microsoft Visual Studio .NET 2003 Academic Edition
 * Microsoft Visual Studio .NET 2003 Enterprise Architect
 * Microsoft Visual Studio .NET 2003 Enterprise Developer
 * Microsoft Visual Studio .NET 2003 Professional Edition

-



This article was previously published under Q323843



For a Microsoft Visual C# .NET version of this article, see 320985.

IN THIS TASK

 * SUMMARY
 * Edit the WebProjectItems.vsdir File
 * Create a Custom Web Form Wizard
 * Create a Custom Web Form Template
 * Test the Link Reference
 * REFERENCES



SUMMARY
This step-by-step article describes how to create a custom Web Form template so that you can include a cascading style sheet (CSS) reference in all Web Forms in a Visual Basic .NET Web project.

Typically, Web site designers must maintain a consistent look and feel on every page for a particular Web site. This article describes how to create a custom Web Form template that contains a link to a CSS style sheet. When you create all Web Forms in an application with this template, you provide an easy way to maintain a consistent design across the site.

The technique that is described in this article is based on the concept of Microsoft Visual Studio .NET Enterprise Templates. For more information, see the &quot;References&quot; section of this article.

back to the top

Edit the WebProjectItems.vsdir File
 In Notepad, open the WebProjectItems.vsdir file from the C:\Program Files\Microsoft Visual Studio .NET\Vb7\VBProjectItems\Web Project Items folder.

-or-

If you are using Microsoft Visual Studio .NET 2003, open the WebProjectItems.vsdir file from the C:\Program Files\Microsoft Visual Studio .NET 2003\Vb7\VBProjectItems folder.  Add the following text to the end of the file: ..\MyCustomWebForm.vsz|{164B10B9-B200-11D0-8C61-00A0C91E29D5}|My Custom WebForm|10|#3063|{164B10B9-B200-11D0-8C61-00A0C91E29D5}|4533| |WebForm.aspx  Save the file.

back to the top

Create a Custom Web Form Wizard
 Open the C:\Program Files\Microsoft Visual Studio .NET\Vb7\VBProjectItems folder.

-or-

If you are using Microsoft Visual Studio .NET 2003, open the C:\Program Files\Microsoft Visual Studio .NET 2003\Vb7\VBProjectItems folder. Copy the WebForm.vsz file to the MyCustomWebForm.vsz file.  In Notepad, open the MyCustomWebForm.vsz file, and then change the Param value as follows: Param=&quot;WIZARD_NAME = MyCustomWebForm&quot; </li> Save the file.</li></ol>

back to the top

Create a Custom Web Form Template
 Open the C:\Program Files\Microsoft Visual Studio .NET\Vb7\VBWizards folder.

-or-

If you are using Microsoft Visual Studio .NET 2003, open the C:\Program Files\Microsoft Visual Studio .NET 2003\Vb7\VBWizards folder.</li> Copy the WebForm folder to a new folder that is named MyCustomWebForm.</li> Open the C:\Program Files\Microsoft Visual Studio .NET\Vb7\VBWizards\MyCustomWebForm\Templates\1033 folder.

-or-

If you are using Microsoft Visual Studio .NET 2003, open theC:\Program Files\Microsoft Visual Studio .NET 2003\Vb7\VBWizards\MyCustomWebForm\Templates\1033 folder.</li>  In Notepad, open the WebForm.aspx file, and then add the following link reference (which appears indented) between the <meta name=vs_targetSchema> tag and the closing tag as follows: ...   <meta name=vs_targetSchema content=&quot;[!output DEFAULT_TARGET_SCHEMA]&quot;> <link id=&quot;link1&quot; rel=&quot;stylesheet&quot; href=&quot;myStyleSheet.css&quot; type=&quot;text/css&quot;> ... </li> Save the file.</li></ol>

back to the top

Test the Link Reference

 * 1) Start Microsoft Visual Studio .NET.
 * 2) On the File menu, point to New, and then click Project.
 * 3) In the New Project dialog box, click Visual Basic Projects under Project Types, and then click ASP.NET Web Application under Templates.
 * 4) On the Project menu, click Add New Item to add a style sheet to the project, and then name the style sheet myStyleSheet.css.
 * 5) Set the background color of the body element to blue for testing purposes.
 * 6) On the Project menu, click Add New Item.
 * 7) Click My Custom Web Form under Templates, name the file, and then click Open to add a custom Web Form to the application. Notice that the style sheet is applied automatically to the new Web Form and that the background is blue.

back to the top

<div class="references_section">