RSS

Select All Text in ASP.NET Text Box or Highlighting the text in a textbox when it gets focus

23 Sep

How do I select all the text in a .Net text box when user clicks in that box to type information?

I have a text box, txtContractorId that has “Enter Id Here” in it by default. When the click in that box I want to select all the text so they can just start typing

In page load:
C#:
TextBox1.Attributes[“onmouseover”] = “javascript:this.focus();”;
TextBox1.Attributes[“onfocus”] = “javascript:this.select();”;

VB:
TextBox1.Attributes(“onmouseover”) = “javascript:this.focus();”
TextBox1.Attributes(“onfocus”) = “javascript:this.select();”

Advertisements
 
Leave a comment

Posted by on September 23, 2010 in ASP Dot Net C#

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: