I have a webpage where there is a text box with some default value.
I need to clear a value from a text box. I have 2 options
1. textbox.text=""; 2. textbox.text.remove(0,length);
Here I would like to know which one I should use. This affects page performance because there are a lot of text fields on the page.
thanks
The best way to do this is:
textbox.text = string.Empty;
Also remember that the string type is immutable!
It doesn’t matter - do what is most readable to you and your colleagues.
Many prefer to use string.Empty.
string.Empty
TextBox.Text = String.Empty;
, .
, javascript, int ? , .
jQuery , , onClick, ClientId :
$('#ctl00_TextBox').click(function() { $('#ctl00_TextBox').val('');
, , :
yourTextBox.Text = String.Empty;
textbox.text="";
foreach (var item in Page.Controls) { if (item is TextBox) { ((TextBox)item).Text = ""; } }
/ ,
textbox.text = "";
, , ( .Remove)
-
textbox.text = String.Empty;
:, -, String.Empty , , "" String.
, , ! , ...