Community discussion forum

Retrieving Text From already populated text box ???

  • 9 months ago
    hi i am doing a project in asp.net(using c#)....I have one problem to ask.... I am having a form in which i m showing 3 text boxes and i m populating these text boxes with some text at the time of page load only....So when this form gets loaded into browser the user will see these 3 text boxes and some text in them. Now I want the user to edit the text given in each text box and when he submits the form i should be able to get those new values(or texts) from those 3 text boxes. I have tried using following code but it is not working for me: START OF CODE: //initially populating text boxes with some text(this code is in Page_Load) textbox1.text="Text1" textbox2.text="Text2" textbox3.text="Text3" //Now trying to get new, updated or edited text after clicking button //(this code is in OnClick Event of the button) string a,b,c; a=textbox1.text; b=textbox2.text; c=textbox3.text; END OF CODE now when i try to get values of a, b and c , surprisingly I get those old values only means a has "Text1" b has "Text2" c has "Text3" even if user actually has changed the text......... So How do I resolve this??? I want the updated text from those text boxes........ Please Help Aniket Harne
    Post was edited on 07/02/2009 12:33:45 Report abuse
  • 9 months ago
    Hi, What you have to be careful of when setting the values in the page load is that page load is called before a postback event handler. so if you haven't wrapped the code in the page load with an if(!ispostback) then it will be set back to the old values when the user clicks the button before the button click event is handled. HTH Simon C

Post a reply

Enter your message below

Sign in or Join us (it's free).

We'd love to hear what you think! Submit ideas or give us feedback