开发者

Focus Does not move on Enter Key in asp.net

Hi Experts I have a web Page i want to move Focus on Enter key on Next Control But it does not work TextBox1 to Text2 focus move Properly But not in Text3 and Text4 and Further. follow in my aspx Code

<asp:TextBox ID="TextBox1" runat="server" />
<asp:TextBox ID="TextBox2" runat="server" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="false" Up开发者_如何学编程dateMode="Conditional">
    <ContentTemplate>
        <asp:TextBox ID="TextBox3" runat="server" />

    </ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="false" UpdateMode="Conditional">
    <ContentTemplate>
        <asp:TextBox ID="TextBox4" runat="server" />

    </ContentTemplate>
</asp:UpdatePanel>


  <asp:TextBox ID="TextBox5" runat="server" />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" />

I Have Write the following JQuery

 $(function () {
            $('input:text:first').focus();
            var $inp = $('input:text');
            $inp.bind('keydown', function (e) {
                var key = e.which;
                if (key == 13) {
                    e.preventDefault();
                    var nxtIdx = $inp.index(this) + 1;


                        $(":input:text:eq(" + nxtIdx + ")").focus();

                }
            });
            });


use the DefaultButton property of the form server tag.

<form id="form1" runat="server" DefaultButton="myButton">
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜