Template Webitem Events

See Also

Tags within an HTML template file can act as event sources if the browser calls the server when the user selects their corresponding HTML elements. Elements call the server if their HTML tags have attributes that contain a URL. For example, when the user selects a hyperlink, the browser sends a URL request to the server to display another page. The hyperlink tag can therefore be treated as an event source in the webclass, because the webclass can intercept this request and process Visual Basic code for it.

When you add a template, Visual Basic scans the file and makes note of each tag within it that can make a server request. The designer displays the attributes of these tags in the right panel. Most tags have only one attribute that can call the server, but some tags, such as the IMG tag, have multiple attributes that can do so. There are three steps to setting up template webitem events:

  1. You choose which of the tag attributes displayed in the Detail panel you want to treat as events.

  2. You perform a process known as "connecting" for each attribute you want to process.

  3. You write code for each connected event.

Connecting an attribute means that you are activating it, or enabling the attribute to be treated as an event. Until an attribute is connected, it does not appear in the Code Editor window for the webclass and you cannot write procedures for it. After the tag attribute is connected, it appears in the Procedure drop-down list in the Code Editor window with the other standard events. You can select the template event and write code for it like you would any Visual Basic event.

A template event differs from a standard event in two main ways:

For More Information   See "Adding HTML Templates to the Webclass" for information on adding a template file to the webclass and viewing the tags that can act as events. See "Connecting Events in a Webclass" for instructions on connecting tags to events and webitems.