Solved

Full select text on gotFocus

Posted on 2004-10-13
4
247 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …

930 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

12 Experts available now in Live!

Get 1:1 Help Now