|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
You don't need a fax machine to get faxes. Get a fax-to-email fax number from CallWave. Try it free.
|
|
#1
|
|||
|
|||
|
Redirect not working...easy question?
I'm building my first asp application and all I want to do is have the form either write "try again" or navigate to a particular page.
You can see what I have so far at: http://www.designdevelopdeliver.com...ontier/test.asp Checking the second radio button works fine, but checking the first one gives an error when it should just redirect the page?? TIA |
|
#2
|
|||
|
|||
|
Code:
<% if Request("rad1")= "" then '*this if is unneeded*
else
If Request.QueryString("rad1") = "radio1" Then
Response.Redirect("test2.asp")
else
Response.Write "...Try Again..."
End If
End If
%>
The probelm is your trying to redirect to another page AFTER the current page is already being written. You have to redirect BEFORE the page is written. What you should do is move all that code top the top of the page. Code:
<%
If Request.QueryString("rad1") = "radio1" Then
Response.Redirect("test2.asp")
Else
strResponse = "...Try Again..."
End if
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<p><%If Len(strResponse) <> 0 then Reponse.write(strresposne) %>... <!-- the rest of the document goes here. -->
|
|
#3
|
|||
|
|||
|
YES!! That did it, thanks.
|
|
#4
|
|||
|
|||
|
Or you can just set the response.buffer to true and then you can redirect whenever you want. IN IIS 5.0 that is the default, but earlier versions you have to do it at the top of each page:
response.buffer = true that's it |
|
#5
|
|||
|
|||
|
Thanks for that tip imbrokn I wasn't aware of that.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > Redirect not working...easy question? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|