challengeAccepted
challengeAccepted

Reputation: 7610

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!

Upvotes: 5

Views: 23225

Answers (3)

NoobProgrammer
NoobProgrammer

Reputation: 1

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

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

Upvotes: 0

fletcher
fletcher

Reputation: 13780

txtbox1.Text = string.Empty;

Upvotes: 9

Jon Skeet
Jon Skeet

Reputation: 1502106

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

Upvotes: 11

Related Questions