Partager via


Visual Basic Concepts

Standard Webclass Events

By default, each template and webitem you add to a webclass has a set of standard events that automatically appear in the Code Editor window. There are three standard events for any webitem:

  • Respond — Sets the default action a webitem takes when activated by a user request.

  • ProcessTag — Processes specific tags in a template file and replaces their content with data you specify. The tags to process are identified by the TagPrefix property for the webitem.

  • UserEvent — Processes webclass events created at run time.

The most commonly used of these is the Respond event. This is the default event for templates and webitems. The webclass fires the Respond event in two situations:  when the webitem is first activated, or when it receives a request from the browser that does not correspond to a template event. The webitem can be activated from the client or the server. A client-side activation occurs when a request contains a reference to the next webitem that should be called. A server-side activation occurs when the NextItem property is set. In either scenario, the Respond event processes the request and sends a response to the browser.

For example, if a user accesses a customer inquiry application and submits a query about whether an order has been shipped, the Respond event might retrieve the request data, process the request by reading a database and retrieving the order detail, then write a reply back to the client that contains the retrieved information.

Note   Unlike template events and custom webitem events, the Respond event does not appear in the designer's Detail panel. You access it from the code window's Procedure drop-down list along with other standard events that are not exposed through an external file or from a user's action in the designer.

Events in an IIS application are fired by actions that occur in the browser. These actions might be initiated by the user selecting an element that contains a URL, or they might be caused by the browser loading a page. For example, when the browser loads a page containing an IMG tag, it fires the event corresponding to that tag when it attempts to resolve the URL for the image and display it. Alternately, a user can select an item such as a hyperlink and manually fire an event. In both cases, the event is fired because the browser accesses a URL that calls the server.

For More Information   See "Transitioning Between WebItems" for more information on the NextItem property. See the "Respond Event," "ProcessTag Event," "TagPrefix Property," and "UserEvent Event" topics in the Language Reference. For information on using the ProcessTag event to process text replacements, see "Performing Text Replacements in a Webclass." For information on using the UserEvent event to process dynamically created events, see "Defining Webclass Events at Run-Time".