I am working on designing a user profile web page in asp.net using c#.
I first load the values of text boxes from database and put them in the text box:
txt_Name.Text = "somestring";
The user can then change the text in the text box to modify their profile.
However when I read txt_Name.Text it shows me the “original” value instead of what the user entered.
More clearly:
- First I set the value of a text box to something:
txt_Name.Text = "somestring"; - Then the user changes the value of the text box to something else in the gui
- Then I read the value of text box:
Response.Write(txt_Name.Text);
In 3 the value is the one from 1 instead of the one from 2
It sounds like you aren’t checking the Page.IsPostBack property (http://msdn.microsoft.com/en-us/library/system.web.ui.page.ispostback.aspx) when you are setting the initial textbox value, so it is always being set no matter how the page is invoked.