Validate Changed Data Before Submitting

J

Johnny

Hello,

I've read somewhere that you can validate form data
before actually submitting it, similar to what validation
controls would do. For example, I have a form that has 2
textboxes. I populate the 2 textboxes with values from
the database. I also have an update button that will
update the values. If I have not made any change to the
data in the textboxes, then I do not want to submit the
data when the update button is clicked. I want to be able
to display a message that says data has not changed. Is
there a way to do this using viewstate or caching the
data.

Thanks,
 
C

Chris Jackson

Viewstate is encrypted data that is viewable only on the server. So, you
have two options:

1. Store the current values in either viewstate or a session variable, then
do a comparison on postback to determine if they have changed prior to
updating the database.
2. Run a javascript on the client on the page load event that stores the
current value of these text boxes. Then, have an <input type="button"
onClick="reviewAndSubmit()"> that calls the reviewAndSubmit function
(JavaScript) which compares the current values to the original values, and
if they are different submit, otherwise redirect.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top