V
Vinay
Hi All:
I have a web form that is displaying some data. What I want to do is:
- Set a flag when the user modifies any data on the form
- Ask the user if the changes are to be discarded when the user hits the exit button
- If user says Yes/OK I continue and quit the screen
- If user says Cancel I stop and return to the screen.
Here is what I have tried:
In the page_load event I have added the following code:
cmdCancel.Attributes.Add("onclick", "return confirm('Quit without saving?')")
But this causes it to fire even if there is no change - I (my client) want this to fire only if there is a change.
So I tried to add the same line in the _TextChanged event of a textbox control. The idea being once the user saves the form contents by hitting 'Save' I will use cmdCancel.Attributes.Remove("onclick") and add it back when _TextChanged detects a change.
This is not working right - I guess the way I have tried to implement it is flawed.
Is there anything other way I can do this?
Any help would be much appreciated.
TIA!
Vinay
(e-mail address removed)
I have a web form that is displaying some data. What I want to do is:
- Set a flag when the user modifies any data on the form
- Ask the user if the changes are to be discarded when the user hits the exit button
- If user says Yes/OK I continue and quit the screen
- If user says Cancel I stop and return to the screen.
Here is what I have tried:
In the page_load event I have added the following code:
cmdCancel.Attributes.Add("onclick", "return confirm('Quit without saving?')")
But this causes it to fire even if there is no change - I (my client) want this to fire only if there is a change.
So I tried to add the same line in the _TextChanged event of a textbox control. The idea being once the user saves the form contents by hitting 'Save' I will use cmdCancel.Attributes.Remove("onclick") and add it back when _TextChanged detects a change.
This is not working right - I guess the way I have tried to implement it is flawed.
Is there anything other way I can do this?
Any help would be much appreciated.
TIA!
Vinay
(e-mail address removed)