Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


how to highlight text in textbox when in focus in

Posted on 2009-07-07
Medium Priority
Last Modified: 2012-05-07
I have a webform with textboxes if a user clicks on the textbox I want all the text in the textbox to be selected (highlighted)
Question by:mugsey
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
LVL 15

Accepted Solution

crisco96 earned 1200 total points
ID: 24793105
<asp:textbox runat="server" text="Some Text" onfocus="this.select()" />

Assisted Solution

Valleriani earned 800 total points
ID: 24793115
If you are looking to highlight text in a textbox then you can do:

TextBox1.Attributes.Add("onFocus", "JavaScript:this.select();") for example!

Assisted Solution

Valleriani earned 800 total points
ID: 24793136
If it's using for example a inputbox, you could also just use:

<input type="text" name="test" onclick='this.select();'/>

Expert Comment

ID: 24793138
Oh my bad crisco96 already stated it above ;)

Featured Post

Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question