Visual Basic Concepts

Firing Custom Events

See Also

Unlike template events, which are fired when the user selects an element in the browser, custom events do not automatically correspond to an element in the browser. To fire these events, you must first use the URLFor method to associate the custom event with an element in the browser. The URLFor method does this by creating a URL that references the custom event. When the user selects the element associated with the URL (for example, a hyperlink), the custom event fires.

For example, suppose you add a custom event named RetrieveAuthorBio to your project, and associate it with a custom webitem called AdditionalInfo. The following screen shows the project.

Sample Project

Suppose you want to fire the RetrieveAuthorBio event from another page in your application. The following code shows how you would use the URLFor method to include a link to this event:

Response.Write "<A HREF=""" & URLFor(AdditionalInfo,"RetrieveAuthorBio") _
& "" ">Retrieve</A>"

This code inserts a hyperlink onto the page that, when selected, activates the AdditionalInfo webitem and fires its RetrieveAuthorBio event.

For More Information   See "URLFor Method" in the Language Reference for more information on syntax and arguments for this method. See "Webclass Events" for more information on custom events.