简体   繁体   中英

How to make a textbox empty in code behind

I have a textbox (txtbox1) which has some value in it. I want to empty the value of textbox. Is that possible in code behind? If yes, how?

Thanks!

Well:

txtbox1.Text = "";

should do it.

(Note that I generally prefer "" to string.Empty in terms of readability. Use whichever you prefer. Ignore any talk about the performance differences between them - most articles I've seen on this are out of date, and any performance difference there might be will be entirely insignificant.)

txtbox1.Text = string.Empty;

use textbox1.Text = null; you can also use textBox1.Text = "";

if you want to put strings in the future textBox1.Text = string.Empty;

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