Click here to Skip to main content
15,896,207 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
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

 
Share this answer
 
Comments
sankar guru 21-Sep-10 1:49am    
Thank U Hiren Solanki.
Hiren solanki 21-Sep-10 1:50am    
Thanks, If you got the answer then please mark it as answer
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 ,
=================================================
C#
<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>
 
Share this answer
 
v2
Comments
rezasaidy 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900