Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - keeping forms filled in after redirect
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

keeping forms filled in after redirect

 Post Reply Post Reply
Author
cullie140 View Drop Down
Newbie
Newbie


Joined: 27 May 2004
Status: Offline
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote cullie140 Quote  Post ReplyReply Direct Link To This Post Topic: keeping forms filled in after redirect
    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

Back to Top
michael View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
Post Options Post Options   Thanks (0) Thanks(0)   Quote michael Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
dpyers View Drop Down
Senior Member
Senior Member


Joined: 12 May 2003
Status: Offline
Points: 3937
Post Options Post Options   Thanks (0) Thanks(0)   Quote dpyers Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
tcampione View Drop Down
Newbie
Newbie
Avatar

Joined: 25 April 2004
Location: United States
Status: Offline
Points: 5
Post Options Post Options   Thanks (0) Thanks(0)   Quote tcampione Quote  Post ReplyReply Direct Link To This Post Posted: 30 November 2004 at 9:17pm

I like the Trim wrapper... very slick.

/*tom*/

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.