Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if textbox text was changed since form was opened

Tags:

c#

textbox

Howdy
I have a form in my application which has 7 textboxes. In the constructor of the form I run the method "MakeText()" that inserts values from a MySqlDataReader into the textboxes.

The user can change the values in those textboxes and when a "submit" button is clicked it will run an update query on the database to write all the changes made.
This is all fine, but I find it a waste of resources to be querying the database even if the user didn't change any of the text in the textboxes.

So I need some way to check if the user changed any of the values in the textboxes after the form was loaded.
I'd like to do this on the application level instead of letting the database handle it.

How can I do this?

EDIT: I just thought of this. Maybe I could put all the values into class strings when the form loads and then just check against that before running the query. Sometimes you just need to put a question into words to think of the answer :D

That's the best I could think up anyway...

like image 478
Steinthor.palsson Avatar asked Dec 13 '22 15:12

Steinthor.palsson


1 Answers

You could store the initial value in the .tag value of the textbox then just do a comparison between current text and the tag text

like image 160
Kurru Avatar answered Feb 11 '23 23:02

Kurru