Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Response.Redirect error

Status
Not open for further replies.

ef61778

IS-IT--Management
Sep 23, 2003
14
US
I am trying to retain the values of an input box after I check to see if all required fields have been filled. If they are not, I want to display the data that they have already typed, and let them finish the form. Here is the Code that I have:

...
<html>
ETC.....
<% if Request("error") = "yes" then %>
<p align="center">&nbsp; <font color="#FF0000" size="4">Fields with * must be completed</font></td>
<% end if %>

<form method="post" action="submit.asp">


<tr>
<td width="50%" height="22" align="left">
<font face = "Arial" size="2">*First Name:</td>
<td width="50%" height="22" align="left">
<input type = "text" size = "30" name = "fname" tabindex="1" value="<%=Request.Form("fname")%>"></td>
</tr>

<tr>
<td width="50%" height="22" align="left">
<font face = "Arial" size="2">*Loan Number:</td>
<td width="50%" height="22" align="left">
<input type = "text" size = "30" name = "lname" tabindex="2" value="<%=Request.Form("lname")%>"></td>
</tr>
etc...


<%
If Request.Form("fname") = "" or _
Request.Form("lname") = "" or _
Response.Redirect "submit.asp?error=yes"
End if

etc...

When I get redirected back to the error page, the values that have been entered are gone. Is there a way that I can retain these values and let the user finish the form?
 
Try using server.transfer instead. It will retain the collection to the next page. In your case the same page

e.g.

If Request.Form("fname") = "" or _
Request.Form("lname") = "" or _
Server.Transfer "submit.asp?error=yes"
End if

I've never tried to add a querystring to the file prior but it's worth a go

___________________________________________________________________
[sub]
The answer to your ??'s may be closer then you think.
Check out Tek-Tips knowledge bank by clicking the FAQ link at the top of the page faq333-3811
[/sub]
 
Response.Redirect should be used before the html starts or rather before the page loads. That's why you are getting an error.



rsshetty.
It's always in the details.
 
It's true you must use Response.Redirect before posting anything to the page (html etc), but this can be bypassed by using

Response.Buffer

and

Response.Flush

hth

simon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top