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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Postback not fetching correct data

Status
Not open for further replies.

M8KWR

Programmer
Aug 18, 2004
864
GB
Hi,

I have a webpage with 1 textbox, which is populated onload, with "TEST DATA"

this is changed to "NEW DATA"

on a button click (in code), when querying the textbox text value, it returns "TEST DATA", and not "NEW DATA" which it has been changed to.

I am unsure what is going on.

Any help would be appreciated.
 

The button click does a postback, which runs the page_load sub again, whcih resets the value of the textbox to "TEST DATA". To keep the value in the textbox, do this in page_load:

If Not IsPostBack Then
TextBox1.Text = "TEST DATA"
EndIf

This will put "TEST DATA" in the textbox only the first time the page loads - i.e., when IsPostBack is False.


I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson

Arrrr, mateys! Ye needs ta be preparin' yerselves fer Talk Like a Pirate Day!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top