Click here to Skip to main content
15,893,487 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In am aspx page, there are a couple of textbox (e.g. txtBoxA and txtBoxB). Ideally, after entering values in txtBoxA, clicking a TAB and RETURN key will make txtBoxB activated. However, when the page is initially loaded, it needs to click twice to activate txtBoxB. How can this problem be debugged? Thanks.
The related codes are below:
ASP.NET
<table>
    <tr>
        <td class="style1">
            <asp:TextBox ID="txtUser" runat="server" Font-Size="Small"  AutoPostBack="true"
                TabIndex="2" onkeydown="onFocus(event);"
                Text =""
                ></asp:TextBox>
        </td>
    </tr>
    <tr>
        <td class="style1">
            <asp:TextBox ID="txtPassword" ClientID="txtPassword" runat="server" Font-Size="Small" AutoPostBack="true"
                TextMode="Password" TabIndex="3" >
            </asp:TextBox>
        </td>

    function onFocus(event) {
        var e1 = document.getElementById('<%=txtUser.ClientID%>').value;
        if (e1.length > 5) {
            if (event.keyCode == 13) {      // RETURN
                event.keyCode = 9;
                return event.keyCode;
            }
        }
    }
    </tr>
</table>
Posted
Updated 27-Mar-15 5:32am
v2
Comments
Anisuzzaman Sumon 27-Mar-15 10:00am    
Please show some code.
s yu 27-Mar-15 11:33am    
See my updated post that contains some related codes. Thanks.

1 solution

Tab will move on to things like links etc too. If the default tab order isn't working for you, try defining your own using tabindex

http://www.w3schools.com/tags/att_global_tabindex.asp[^]
 
Share this answer
 
Comments
s yu 27-Mar-15 11:34am    
tabIndex is set for each related control. Not a tab index issue. Thanks.
s yu 30-Mar-15 12:16pm    
after set AutoPostBack="false" (for the textbox), the problem was gone.
F-ES Sitecore 30-Mar-15 12:41pm    
This is why it is important to post the relevant code when asking a question :) If you had posted the code someone would have spotted that was the problem quite quickly.

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