Visual Basic Concepts

Navigating Between Webclasses

See Also

On occasion, you may want to create an application that has more than one webclass. You might do this if you want to encapsulate certain functionality within one webclass and reuse it in other locations. For example, you might want to use a webclass to handle customer order processing, then access this application from another webclass that also must perform these same processes.

If you are working in an IIS application with multiple webclasses, you can use the Redirect method to navigate from one webclass to another. A redirect is generally placed in the Respond event for a webitem. When a redirect is called in an event procedure, the run-time DLL suspends processing on the current webclass, shifts focus to the indicated webclass, and launches its BeginRequest event. Control can be returned to the original webclass by using another redirect.

Note   Each webclass in your project has its own .asp file, generated when you test or compile your project. You should specify the full path to this file in your redirect statement.

The following code shows an example of a redirect. The code in this example responds to the Click event for a button named "SearchForm" on a template called "OrderSearch." The webclass checks to see whether the action was fired as a result of a search request. If so, it uses the Request object to retrieve information from the form. If not, the server redirects to the first page in the application.

Private Sub OrderSearch_SearchForm()
   'if a search was initialized, retrieve form arguments
   If Request.Form("ACTION") = "Search" Then
      sCustMun = Request.Form("custNO")
      sOrderNum = Request.Form("orderNO")
      sLastName = Request.Form("custLN")
      'Navigate to an order status page
      Set NextItem = OrderStatus
   Else
      'if not, redirect to the opening page
      Response.Redirect "http://www.mycompany-inc-10.com/mydirectory/
      Project1_Welcome.asp"
   End If
End Sub

For More Information   See "An Introduction to Webclasses" for more information about how an ASP page is used in a webclass.