为了账号安全,请及时绑定邮箱和手机立即绑定

ASP,在 Enter 之后聚焦文本框

ASP,在 Enter 之后聚焦文本框

aluckdog 2022-08-18 15:58:28
我有一个问题,我有一个应用程序,用户必须尽可能少地使用鼠标,所以他们将只使用键盘插入条目。为此,我使用的是模态弹出窗口,每次用户按输入时,模态都已准备好进入下一个条目。但为此,第一个模式文本框在每个回车键之后聚焦是必要的。我在实现这一点方面遇到了问题...我的代码:一个按钮只需调用模态:<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>
查看完整描述

2 回答

?
小怪兽爱吃肉

TA贡献1852条经验 获得超1个赞

不要只是 ,试试这个:.Focus

Form.DefaultFocus = txtLogIng_Id1Des.UniqueID;


查看完整回答
反对 回复 2022-08-18
?
守着一只汪

TA贡献1872条经验 获得超3个赞

我使用jq找到了一个解决方案:


<!-- jq + js para que con c/enter se ubique el focus en el 1er Textbox  -->

<script type="text/javascript">

    $(document).ready(function () {

        console.log('Aqui estoy'); // just checking

        document.getElementById('<%=txtLogIng_Id1Des.ClientID%>').focus();

    });

</script>


查看完整回答
反对 回复 2022-08-18
  • 2 回答
  • 0 关注
  • 80 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号