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!

Getting the value of form items when the page loads

Status
Not open for further replies.

SuperSal

Programmer
Mar 13, 2007
33
Hi everyone, I have got a form which opens when a user wants to edit a customers details. When the page initially loads the customers details are displyed in text boxes and the user can edit any of these details and press an update button. After this has been done as well as the details being updated in the database an email is sent out to store managers giving details of this change.
In the email I need to show the details of how the customers details were before (on page load) and what they have been changed to.
My problem is that I need to grab the details of the form objects when the page initial loads to be emailed. I can get the values with Javascript but then cannot put these variables into the asp email code.
Is there any way of getting the value of form fields when the page initially loads via asp? Or even getting the values in Javascript and them sending them to asp?

Thanks
Sally
 
if you're using asp (not asp.net) please use forum333.

if you're using asp.net then you need to understand how the server (.net framework) interacts with the client (javascript, css, html). you're better of storing the initial state of the object in viewstate/session, editing, saving, emailing with old values in state bag and new values from controls/db.

Note: this setup could cause a concurrency issue. You should check the record hasn't been updated, since it was loaded into a state bag before saving.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Hi Jason, At the moment most of the pages are written in asp but we are trying to move over to .NET so a solution in either would be fine.

Can you explain what you mean by "you're better of storing the initial state of the object in viewstate/session, editing, saving, emailing with old values in state bag and new values from controls/db.
"

I understand that I can get the updated value from the database after it has been updated, thats fine, its just getting the initial values of the form items when the page loads that I am having trouble with.

Thanks
Sally
 
state bags are temporary storage locations.
viewstate - unqiue to a page and current postbacks
session - unique to a user
application - global to all users for the website
cache - global to all users

when you load the record on inital load store the record in either viewstate or session (I would use viewstate). then on following postbacks pull the information from the viewstate instead of the db. and use these as your original values for the email.

this could create a concurrency issue, so remember to validate the object in session = the object in the db when you update it. otherwise the original values, won't be.

thinking about this some more a better option would be to a have data objects which can hold original values (defaults or db values) and new/current values (loaded from db or modified values). then you could easily map the current value to the previous value.

if you're new to asp.net research the asp.net page life cycle, this will help you understand what is happening when.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top