views:

23

answers:

2

Hi!

I want to check if there have been any changes to a form on my ASP.NET webpage, What are my options?

Should i check if the viewstate has changed or should create a flag in the code-behind, triggered by webcontrol events like TextChanged for Textboxes or SelectedIndexChanged for Dropdownlists?

+1  A: 

Easy way: submit that form, and at server-side, compare sent values with those stored in your data layer.

Rubens Farias
Okey i will try to figure out how i do this, thank you!
EasyDot
+1  A: 

You could store the sent values in attributes. Something like:

Textbox1.Text = <Sent Text>
Textbox1.Attributes.Add "OldText",Textbox1.Text

On postback, you can compare:

If Textbox1.Text <> Textbox1.Attributes("OldText") Then
   ' Text is different

You would have to do that for every control in your form. Of course, you could write a procedure to do this in a more automatic way, like iterating through all your controls.

ACB
Maybee this is the best solution for me, i shall figure out how to implement this solution to dropdownlist also.
EasyDot