Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
how to focus next textbox when we press enter key on previous textbox using tab order , because   i couldnt sent the next co
ntrol id to the javascript.
Posted 20-Sep-10 0:51am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
Comments
usankardurai at 21-Sep-10 1:49am
   
Thank U Hiren Solanki.
Hiren Solanki at 21-Sep-10 1:50am
   
Thanks, If you got the answer then please mark it as answer
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Hai Friends,
 
You dont Have to send control id to move next control, u just assign unique tabindex to the each control on the page,
 
Put the coding in <Head> tag of asp.net file ,
=================================================
<script language ="javascript" type ="text/javascript" >
function FocusNext(cid)
{
 var i=document.getElementById (cid.id).getAttribute ('tabindex');
 var iKeyCode = 0;
    if (window.event)
    iKeyCode = window.event.keyCode
     else if (e)
     iKeyCode = e.which;
     if (iKeyCode == 13)
     {
         var ctrl=document.all;
         for(var count = 0; ctrl.length ; count ++)
            {
               if(ctrl[count].tabIndex == i+1)
                {
                       ctrl[count].focus();
                 }
             }
      }
     else
     return true;
}
</script>
 
==================================================================
 
Add OnKeyPress Event in TextBox
================================
<asp:TextBox ID="TextBox1" runat="server" TabIndex="1" Width="50px"  onKeyPress="FocusNext(this)"></asp:TextBox>
  Permalink  
v2
Comments
rezasaidy at 27-Feb-12 7:29am
   
how can pushing enter and after that focous on Button for reching text box.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 515
1 Maciej Los 349
2 Richard MacCutchan 220
3 BillWoodruff 209
4 Mathew Soji 160
0 OriginalGriff 8,654
1 Sergey Alexandrovich Kryukov 7,407
2 DamithSL 5,639
3 Maciej Los 5,229
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web02 | 2.8.1411023.1 | Last Updated 21 Sep 2010
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100