?
Solved

Full select text on gotFocus

Posted on 2004-10-13
4
Medium Priority
?
254 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 200 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

771 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