Visual Basic Concepts

Step Seven: Add Navigation Using the URLFor Method

The final step on the Customers page is to dynamically create a hyperlink that returns the user to the Menu page. You use the URLFor method to do this. URLFor is an easy way of indicating that the webclass should move to a different webitem — instead of entering the fully parsed HTTP URL that indicates how to access a webitem, you simply enter the name of the webitem you want to call.

To add a URL to the customer page

  1. In the ShowIDs_Respond event, modify the final .Write statement you added in Step Six so that it looks like this:

    Response.Write "</table><br><a href=""" & URLFor(Menu) & _
        """>Back to Menu</a></BODY></HTML>"
    

In this code, the <a href> tag is an ordinary HTML hyperlink, but it points to a webitem in the webclass rather than to a Web site such as https://www.microsoft.com. When the link is selected, the webclass will locate and display the Menu webitem.

You can now run your webclass project to test your application's buttons. You should see the following page when you click the Show All Customers button:

Next Steps

You now have a functional, data-aware webclass. Note that the hyperlinks on the Customers page are not working yet. What remains to be done is to make these links work by creating a Details page to show more information about each row as it's selected.

There are several advanced features of webclasses that you will use in this section. You will:

  • Create an HTML template with replacement tags that can be populated at run time.

  • Write code to process the replacement tags.

  • Write code to process the events that are generated at run time.