Scenario: Two textboxes on a form with multiple input fields. TextboxA and TextboxB, we'll call them. The first time the page loads, these fields are Enabled = false. A selection in a dropdownlist "opens" the form to editing, but by default, TextboxB is
.ReadOnly = true. Some javascript is added to the form which evaluates the value of TextboxA in the onBlur. If the text is a particular value, then TextboxB.readOnly = false, allowing the user to type a value.
Works like a charm.
Later on in the form, TextboxC has a TextChanged event and causes a PostBack. When looking at TextboxB.Text, it is empty, i.e. the user input is lost. Uh oh.
But let's let it keep going. We'll type the value again into TextboxC. And then continue input. TextboxD further into the form has a TextChanged event and causes a PostBack as well. And now, TextboxB.Text has remembered the input and all is well.
Question is, why on earth is the first postback after typing in a value in TextboxB losing the value of the textbox?
I have extensively stepped through the debugger to look for any code that modifies the value of the textbox. I have IsPostBack checks and all that jazz. What am I missing? What should I look for?
The aim of an argument or discussion should not be victory, but progress. - Joseph Joubert
If my post has helped you, please "Mark as Answer".
thermalnoise
Participant
783 Points
161 Posts
Textbox Value lost on Postback, but not on subsequent Postbacks
Jun 13, 2006 05:52 PM|LINK
Works like a charm.
Later on in the form, TextboxC has a TextChanged event and causes a PostBack. When looking at TextboxB.Text, it is empty, i.e. the user input is lost. Uh oh.
But let's let it keep going. We'll type the value again into TextboxC. And then continue input. TextboxD further into the form has a TextChanged event and causes a PostBack as well. And now, TextboxB.Text has remembered the input and all is well.
Question is, why on earth is the first postback after typing in a value in TextboxB losing the value of the textbox?
I have extensively stepped through the debugger to look for any code that modifies the value of the textbox. I have IsPostBack checks and all that jazz. What am I missing? What should I look for?
If my post has helped you, please "Mark as Answer".
sdiazc
Member
6 Points
3 Posts
Re: Textbox Value lost on Postback, but not on subsequent Postbacks
May 04, 2012 10:06 PM|LINK
I know this is an old post, but i'm having a similar problem.. were you able to find a solution for this behaviour??
Thanks in advance...