VB6 beginners tutorial - Learn VB6

Advanced VB6 tutorial - Learn Advanced VB6

Systems Analysis - System analysis and Design tutorial for Software Engineering

You are here: Visual Basic > Advanced VB6 tutorial > Chapter 17

Programming With an HTML Template

You can associate a WebClass object with an existing HTML file. This file then becomes the HTML template for the WebClass.

To associate an HTML template with a WebClass, follow these steps:

17.1 Associating an HTML Template With a WebClass Object

  1. Use a text editor or HTML editor to create a standard HTML file in a different directory from your project.

  2. Make sure that you have saved your IIS project before proceeding.

  3. In your IIS project, open the WebClass designer and right-click on HTML Template WebItems to bring up the shortcut menu.

  4. On the shortcut menu, choose Add HTML Template to bring up the File Browse dialog box.

  5. Navigate to and select the HTML file.

  6. Double-click the WebClass designer to bring up its Code window. Comment out or delete the default code in the Start event procedure.

  7. In the Start event procedure of the WebClass designer, write a line of the form:


    where TemplateName is the name within the project of the HTML template that you just added. (If you did nothing to change it, the default name will be Template1.)

  8. If you run the application now, you will see your default HTML page displayed in the browser.

At its simplest, an HTML template can contain ordinary, HTMLstandard code. The WebClass would just pass such a file through to client browsers, adding no more functionality. As you might imagine, this would be a gross under-use of the potential of the HTML template. The true power of an HTML template lies in the extra functionality that it can give to a WebClass in your IIS application. You can enhance normal HTML functionality in several ways with an HTML template:

  • You can embed special substitution tags in the HTML file and replace those tags with your own programmatically determined values before submitting the HTML to the client browser.

  • You can associate any standard HTML tag that uses a URL (such as an IMG tag that refers to an image file location) with an event in your WebClass.

The following section discusses these features.

Substitution Tags

NOTE - Editing the HTML Template: File Although you added the HTML template from a different directory, VB will make a copy of the file in the project directory. You should edit the copy in the project directory after you have added the file to the project.


<< Previous | Contents | Next >>

Home | About Us | Privacy Policy | Contact Us

Copyright © | All Rights Reserved