By 06/02/2014 7 Comments

How To Click and Highlight Text in ASP.NET TextBox using jQuery

Why we use this ?

  • The highlight feature could be used in a scenario where this is a frequent requirement to copy and paste text. The technique shown here saves the user an extra step to first select the text and then copy

Following  code which helps us for select text in a text box control in asp.net using jquery

Jquery Code snippet

<script type="text/javascript" src="Scripts/jquery-1.8.2.js"></script> <!-- call jquery file or library into asp.net page --->
    <script>
        $(document).ready(function() {  // this is a function which is called by browser when it loads a webpage

            $('[id$="TT_TextBox1"]').click(function () { // get TextBox object, trigger it's click event and call anonymous function
                $(this).focus().select(); // call this functions and highlight the text inside TextBox control
            });
        });

    </script>

ASP.NET Code snippet

<!--- Following is the code which renders textBox and a label control on browser-->
<asp:Label runat="server" Text="Click in the text box to select all the text automatically"></asp:Label>
        <br/>
        <asp:TextBox ID="TT_TextBox1" runat="server" Text="Click Here to Select Text" />






Posted in: ASP.NET, jQuery

Leave your valuable Comment

Have a natural attraction for women cosmetics and replica watches uk clothes, no
more than two for men the most attractive one, is to make their own driving experience, happy and can serve as the facade of the car, another is to highlight the taste edify sentiment rolex replica watch. The replica rolex is undoubtedly the most fashionable accessories, wear a suit to attend the activities, but also get a decent match on the replica watches .