Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing TextBoxes

Status
Not open for further replies.

AtariJag64

Programmer
Mar 4, 2002
8
US
I start out the page by setting the TextBoxes's Text equal to some field in a database. I change the Text in that box however that acctual value when it gets posted back to the database does not change from the original.

for example:

TextBox1.Text = "Hello";

Now, I change the text in the box in the webform from "Hello" to "Goodbye".

This, however, doesn't change the value of TextBox1.Text.

I've tried to add an actionListener to the text box, but this doesn't seem to help.

Any suggestions?
Thanks,
-Chris
 
If you are populating the textbox when the page loads and you do not account for postback, then when the page reloads (after clicking a button, for example) then the value will be repopulated.

The the page load, add something like:
if(this.IsPostBack)
{
// Do processing here that you do everytime
// except the first load
}
else
{
// initialize text boxes here
}

Lookup help on: Web Forms Page Processing

Using the Page.IsPostBack property, check whether this is the first time the page is being processed.
If this is the first time the page is being processed, perform initial data binding.
Otherwise, restore control values.
Read and update control properties.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top