猿问

ASP,在 Enter 之后聚焦文本框

我有一个问题,我有一个应用程序,用户必须尽可能少地使用鼠标,所以他们将只使用键盘插入条目。为此,我使用的是模态弹出窗口,每次用户按输入时,模态都已准备好进入下一个条目。但为此,第一个模式文本框在每个回车键之后聚焦是必要的。我在实现这一点方面遇到了问题...我的代码:


一个按钮只需调用模态:


<asp:Button ID="btnLotIng_Lotear" runat="server" Text="Crear Lotes" class="btn btn-primary btn-block mb-3"

                                OnClick="Crear_Lotes" OnClientClick="focusear()"  />

面板:


<asp:LinkButton ID="lnkFake_LotIng" runat="server"></asp:LinkButton>

<asp:Panel ID="pnl_LotIng" runat="server" CssClass="modalPopup" Style="display: none;">

    <div style="overflow-y: auto; overflow-x: hidden; max-height: 750px; max-width: 1100px">

        <div class="modal-body">

            <table class="table table-sm table-hover">

                <tbody>

                    <tr>

                        <th scope="row">Lote Numero</th>

                        <td colspan="3">

                            <asp:TextBox ID="txtLogIng_LotNum" runat="server" CssClass="form-control inputfield text-uppercase"

                                Font-Size="Large" Font-Bold="true" onkeydown="LotNKey(event)"></asp:TextBox>

                        </td>

                    </tr>

                    <tr>

                        <th scope="row">Id1Desde</th>

                        <td>

                            <asp:TextBox ID="txtLogIng_Id1Des" runat="server" CssClass="form-control inputfield text-uppercase"

                                Font-Size="Small" onkeydown="id1DKey(event)"></asp:TextBox>

                        </td>

                        <th scope="row">Id1Hasta</th>

                        <td>

                            <asp:TextBox ID="txtLogIng_Id1Has" runat="server" CssClass="form-control inputfield text-uppercase"

                                Font-Size="Small" onkeydown="id1HKey(event)"></asp:TextBox>

                        </td>

                    </tr>

                    <!-- here go other rows with textboxes -->


                </tbody>


aluckdog
浏览 81回答 2
2回答

小怪兽爱吃肉

不要只是 ,试试这个:.FocusForm.DefaultFocus&nbsp;=&nbsp;txtLogIng_Id1Des.UniqueID;

守着一只汪

我使用jq找到了一个解决方案:<!-- jq + js para que con c/enter se ubique el focus en el 1er Textbox&nbsp; --><script type="text/javascript">&nbsp; &nbsp; $(document).ready(function () {&nbsp; &nbsp; &nbsp; &nbsp; console.log('Aqui estoy'); // just checking&nbsp; &nbsp; &nbsp; &nbsp; document.getElementById('<%=txtLogIng_Id1Des.ClientID%>').focus();&nbsp; &nbsp; });</script>
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答