Print Page | Close Window

keeping forms filled in after redirect

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=12618
Printed Date: 30 March 2026 at 9:50pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: keeping forms filled in after redirect
Posted By: cullie140
Subject: keeping forms filled in after redirect
Date Posted: 19 November 2004 at 10:14pm

I have just finished my form to the way I like it for validation thanks to help from my previous post. But now the problem I have is that when a validation error occurs I send the user back to the registration page with a query in the URL like Name=False only the entire form is cleared and they must start all over again. Is there a way with asp to keep the forms filled in except certain ones like the password and the fields with errors. Thanks for any help.

The form I am working on is http://www.roadhousegossip.com/bdecom/register.asp - http://www.roadhousegossip.com/bdecom/register.asp




Replies:
Posted By: michael
Date Posted: 19 November 2004 at 11:10pm
aaah the beauty of viewstate. You can set a cookie for the fields, pass the fields back as a querystring and or form and on the page you read the values in, if the cookie or form or querystring exists fill the form, if not it's blank

-------------
http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker


Posted By: dpyers
Date Posted: 19 November 2004 at 11:34pm

Create a global.asa file in the root of your web and dim some session variables in the Session_OnStart subroutine - e.g.

Sub Session_OnStart
    Dim Save_First
    Dim Save_Last
End Sub

In your registration page assign the value of each session variable to its respective form field - e.g.

  <p> First Name: 
    <input name="First" type="text" id="First" value="<%=Session("Save_First")%>">
    Last Name:
    <input name="Last" type="text" id="Last" value="<%=Session("Save_First")%>">
  </p>
 The first time through, each session variable will be blank

In your form handler (looks like it's form.asp), assign the contents of each form field to its respective session value.

Session("Save_First") = Trim(Request.Form("First"))
Session("Save_Last") = Trim(Request.Form("Last"))
You can do this either at the beginning of the form handler, or only if it fails validation. Now if you redirect back to the registration page, the value of each field will be populated with the session value.
I wrapped the form fields in the "Trim" function to remove leading and trailing spaces - also useful if the user just put in a space instead of valid content. 



-------------

Lead me not into temptation... I know the short cut, follow me.


Posted By: tcampione
Date Posted: 30 November 2004 at 9:17pm

I like the Trim wrapper... very slick.

/*tom*/



-------------
http://www.audience-response-rentals.com/ - Audience Response Systems | http://www.nyrfanclub.com/ - NY Rangers Fan Club



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net