The Write Method

The Redirect Method

Use the Redirect method to jump to a different Web page.

When you use the Redirect method of the Response object, you provide the URL as an argument to the method.

Syntax

Use the following syntax for the Redirect method:
 Response.  Redirect   URL  

The URL specifies the absolute or relative location to which the Web browser is redirected.


Note

If you use the Redirect method after information has already been sent to the user , an error message will be generated.


Example

This example uses the Redirect method to display a page in high or low resolution, depending on the screen resolution of the user's computer:
 <% If Request.ServerVariables("HTTP_UA_PIXELS") = "640x480" Then Response.Redirect "lo_res.htm" Else Response.Redirect "hi_res.htm" End If %> 

Posting Values to a Form

With ASP, you can define a form that posts its input values back to the .asp file that contains the form. To do this, break the ASP file into two parts : One part displays the form and a second responds to the submitted form.

To determine whether or not the form requests an ASP, test the HTML controls to see if they contain values. If the controls do not contain values, the user has not yet submitted the form; therefore, you need to display a blank form that the user can complete and submit.

Example

This example displays a blank form:

 <% If IsEmpty (Request("txtName")) Then ' Display form Else ' Form was submitted End If %> 


Microsoft Windows Architecture Training
Microsoft Windows Architecture for Developers Training Kit
ISBN: B00007FY9D
EAN: N/A
Year: 1998
Pages: 324

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net