Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a textbox empty in code behind

Tags:

c#

asp.net

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!

like image 828
challengeAccepted Avatar asked Aug 17 '10 19:08

challengeAccepted


2 Answers

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.)

like image 62
Jon Skeet Avatar answered Oct 19 '22 11:10

Jon Skeet


txtbox1.Text = string.Empty;
like image 44
fletcher Avatar answered Oct 19 '22 11:10

fletcher