简体   繁体   中英

ASP.NET Control not passing through updated string to code behind

I have a bit of an issue I hope you guys can give me a bit of help with.

I have an ASP.NET textbox control. In my code behind I throw text in there with

txtTextbox.Text = variable;

Variable being a value I get from a database in earlier lines of code.

So after this, when I edit the text in that text box, in the button click event handler I get the new value with

string variable = txtTextbox.Text;

The issue is, now this 'new' value is just giving me the original value I placed in the textbox. Not the one I eddited in my application.

Any help greatly appreciated. Thanks.

Need to check for post back when loading data in to textbox, Otherwise data gets binded to textbox when button click happens

if(!IsPostback)
{
//load data
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM