E
epigram
I've tried asking this question several times and have received many good
answers, but ones that don't quite answer my question. This leads me to
believe that I am trying to do something very awkward or I don't know how to
pose the question correctly. Let me try again. I appreciate any input!
I have an asp.net web form with a TextBox control and a submit button. The
TextBox control's text property is set on the server before it is first
displayed to the user. When the form is posted back, because of the user
clicking the submit button, I am trying to determine what the value of the
TextBox control's text property was originally set to so that I can manually
compare it to what the text property is currently set to. I know I can
setup an event handler to capture the TextBox's text change event, but I
don't want to do that. I thought I could obtain the TextBox control out of
the ViewState. I tried doing this, in my button click event handler, with
code such as:
TextBox tbxSaved = (TextBox)ViewState["myTextBoxId"];
where myTextBoxId is the value of the id attribute of the TextBox control on
the form. It comes back as <undefined value>.
If you want the rest of the story here I've actually got several TextBox
controls on my form. Depending on which ones change I will have to execute
different db updates. It seems odd to respond to text change events for all
these controls and maybe set some dirty flags for each control and determine
later (in some other asp.net page event I suppose) which controls had
changed and determine my course of action. What I want to do is in the
button click event handler manually determine which controls have changed
and determine my course of action all from within this handler. The need I
have seems very routine, so clearly there is a easy way to handle this. It
just currently escapes me.
Any help would be much appreciated! Thanks!
answers, but ones that don't quite answer my question. This leads me to
believe that I am trying to do something very awkward or I don't know how to
pose the question correctly. Let me try again. I appreciate any input!
I have an asp.net web form with a TextBox control and a submit button. The
TextBox control's text property is set on the server before it is first
displayed to the user. When the form is posted back, because of the user
clicking the submit button, I am trying to determine what the value of the
TextBox control's text property was originally set to so that I can manually
compare it to what the text property is currently set to. I know I can
setup an event handler to capture the TextBox's text change event, but I
don't want to do that. I thought I could obtain the TextBox control out of
the ViewState. I tried doing this, in my button click event handler, with
code such as:
TextBox tbxSaved = (TextBox)ViewState["myTextBoxId"];
where myTextBoxId is the value of the id attribute of the TextBox control on
the form. It comes back as <undefined value>.
If you want the rest of the story here I've actually got several TextBox
controls on my form. Depending on which ones change I will have to execute
different db updates. It seems odd to respond to text change events for all
these controls and maybe set some dirty flags for each control and determine
later (in some other asp.net page event I suppose) which controls had
changed and determine my course of action. What I want to do is in the
button click event handler manually determine which controls have changed
and determine my course of action all from within this handler. The need I
have seems very routine, so clearly there is a easy way to handle this. It
just currently escapes me.
Any help would be much appreciated! Thanks!