Visual Basic Concepts
Adding Custom Webitems to the Webclass
You add custom webitems to your webclass to specify programmatic resources, rather than file-based resources, for your application. Unlike template webitems, which are linked to and manipulate HTML pages, custom webitems are containers that generally group a set of code procedures you want the webclass to be able to access from multiple places in the application.
There are several ways in which custom webitems are useful:
Custom webitems can help you produce more modular or structured code. For example, suppose you have several HTML template files in your webclass that all contain a single image, called logo.gif, that is stored in a database. Rather than writing a separate procedure to retrieve and display this image for each IMG tag event in the webclass, you can add a custom event to a custom webitem and define the image retrieval procedure there. Each webitem can then access the custom webitem's event, using the URLFor method, instead of handling the procedure itself.
Custom webitems can provide a good way to encapsulate code in your IIS application that produces a frequently used HTML response, such as a standard header or a table.
Custom webitems can allow you to send a response to the browser at times when a template file is not a good solution or when a template is not available. For example, if you want to dynamically generate a page in response to a search request, you could do this by using a template file and parsing replacements, or you could generate the entire page within a custom webitem's Respond event.
To add a custom webitem to a webclass
In the Webclass Designer window, click the Add Custom WebItem button on the toolbar. A webitem appears in the treeview, beneath the Custom WebItems folder.
To rename the webitem, use the Properties window to specify a name.
To remove a custom webitem from the webclass
- Right-click the webitem and click Delete.
For More Information See "Webclass Events" for more information on custom events. See "Specifying URLs for Webitems" for more information on using the URLFor method.