Solved

Full select text on gotFocus

Posted on 2004-10-13
4
244 Views
Last Modified: 2012-06-27
Hi.

How i can select all text into one textbox when the object got focus
0
Comment
Question by:lem2802
  • 2
  • 2
4 Comments
 
LVL 5

Expert Comment

by:stumpy1
ID: 12300201


Say you have the following HTML in your aspx page. I am only
<HEAD>
<script language="javascript">
<!--
function test()
{
      Form1.TextSearch.select();
}
// -->
</script>
</HEAD>

...

<form id="Form1" method="post" runat="server">
      <asp:TextBox id="TextSearch" style="Z-INDEX: 102; LEFT: 40px; POSITION: absolute; TOP: 40px" runat="server" onfocus="test()">test</asp:TextBox>
</form>

Now when the textbox receives focus, the onfocus event is fired and the text in the textbox is selected
0
 
LVL 17

Author Comment

by:lem2802
ID: 12300544
ok.
but can i make one geheric function for all textboxes
0
 
LVL 5

Accepted Solution

by:
stumpy1 earned 50 total points
ID: 12300655
I think you should be able to change the test() function so that it dynamically takes the nameof the control that you want to work with as a parameter.

Eg. pseduo code

<HEAD>
<script language="javascript">
<!--
function test(ctl)
{
     Form1.ctl.select();
}
// -->
</script>
</HEAD>

...

<form id="Form1" method="post" runat="server">
     <asp:TextBox id="Text1" runat="server" onfocus="test(Text1)"></asp:TextBox>
     <asp:TextBox id="Text2" runat="server" onfocus="test(Text2)"></asp:TextBox>
     <asp:TextBox id="Text3" runat="server" onfocus="test(Text3)"></asp:TextBox>
     <asp:TextBox id="Text4" runat="server" onfocus="test(Text4)"></asp:TextBox>
</form>
0
 
LVL 17

Author Comment

by:lem2802
ID: 12301369
Ok man thanks...
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

743 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now