Solved

Full select text on gotFocus

Posted on 2004-10-13
4
253 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:Elvio Lujan
[X]
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
  • 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 18

Author Comment

by:Elvio Lujan
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 18

Author Comment

by:Elvio Lujan
ID: 12301369
Ok man thanks...
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

717 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