Not getting updated Textbox Text
-
I have a simple page that allows the user to update a few textboxes on a page. On the Page Load, it sets the text for several text boxes from data received through a class library I created. This part works. The problem is that I have a button which is supposed to take the changes I made to those text boxes and call another method in my class library. However, I've noticed that instead of the changes I made to the text boxes being past, their original values are instead. For example, in the Page Load, I may have something like: txtCity.Text = Library.GetCity(); For the click event for my Update Button, I have something like Library.SetCity(txtCity.Text); If the City text box's text was set to Los Angeles on the page load and then if I change it to New York City then click the Update button, Los Angeles is passed instead of the new city. Any ideas about what I'm doing wrong? Thanks, John Wood
-
I have a simple page that allows the user to update a few textboxes on a page. On the Page Load, it sets the text for several text boxes from data received through a class library I created. This part works. The problem is that I have a button which is supposed to take the changes I made to those text boxes and call another method in my class library. However, I've noticed that instead of the changes I made to the text boxes being past, their original values are instead. For example, in the Page Load, I may have something like: txtCity.Text = Library.GetCity(); For the click event for my Update Button, I have something like Library.SetCity(txtCity.Text); If the City text box's text was set to Los Angeles on the page load and then if I change it to New York City then click the Update button, Los Angeles is passed instead of the new city. Any ideas about what I'm doing wrong? Thanks, John Wood
-
Hi there, It sounds like you don't place your init code in the Page_Load in the if(!IsPostBack) conditional statement. If this is the case, it will reset the values of the textboxes when the page posts back.