Form post doesn’t contain textbox data [ASP.NET C#],
I have several “ASP:TextBox” controls on a form (about 20).
When the form loads, the text boxes are populated from a database.
The user can change the populated values, and when they submit the form, I take the values posted to the server and conditionally save them (determined by some business logic).
All but 1 of the text boxes work as intended.
The odd box out, upon postback, does not contain the updated value that the user typed into the box.
When debugging the application, it is clear that
myTextBox.Text reflects the old, pre-populated value, not the new, user-supplied value.
Every other box properly shows their respective user-supplied values.
I did find a workaround.
My solution was to basically extract the text box’s value out of the
Request.Form[myTextBox.UniqueID], which does contain the user-supplied value.
What could be going on, here?
As I mentioned, the other text boxes receive the user-supplied values just fine, and this particular problematic text box doesn’t have any logic associated to it — it just takes the value and saves it.
The main difference between this text box and the others is that this is a multi-line box (for inputting notes),
Are you initially loading the data only when !Page.IsPostBack? Also, is view state enabled for the text box?
That’s the answer Form post doesn’t contain textbox data [ASP.NET C#], Hope this helps those looking for an answer. Then we suggest to do a search for the next question and find the answer only on our site.
The answers provided above are only to be used to guide the learning process. The questions above are open-ended questions, meaning that many answers are not fixed as above. I hope this article can be useful, Thank you