View Single Post
  #28 (permalink)  
Old June 24th, 2004, 04:51 AM
Imar's Avatar
Imar Imar is offline
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts

I completely agree with Rod on this one. Storing the values in Sessions in this scenario is very bad practice.

The very first solution suggested by Vijay is the best way to go. It's short, it's simple, it won't screw with your server's memory, it's easily expandable, it's easy to understand etc etc.

It *is* a good solution, because it keeps the values to the smallest scope possible. When the page first loads, Request.Form("submit") will be empty, so all variables, like testVal are empty as well.
Then the user fills in a couple of text boxes and hits the submit button. The page is sent to the server where Request.Form("submit") will be true. The values of each HTML form control are assigned to local variables (like testVal in Vijay's scenario) and then tested for validity. If they are valid, the code can proceed and do what it needs to do. If some of them are invalid, a message can be displayed. But more importantly, the variables like testVal still have their value, so they can be used to repopulate the HTML form controls. This way, the user can see a mistake was made, the form retains its values and they can easily fix whatever they need to fix.

Clean, crisp and simple.

Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Slowly Goes the Night by Nick Cave and the Bad Seeds (Track 7 from the album: Tender Prey) What's This?
Reply With Quote