Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

231
Visualizações
How to set DefaultButton to a asp:TextBox derived from ASP UserControl (ASCX) to act after pressing Enter on keyboard

I have an asp:TextBox derived from an ASP User Control (ASCX).

<div style="text-align: center;">
      <h2>
         <asp:Panel ID="pnlResetPin" DefaultButton="Button_ResetPwd">
             <ctrl:ScannerReset ID="ScannerReset_ID" Width="200px" LabelText="ID" runat="server" Visible="True"></ctrl:ScannerReset>
             <br />
             <asp:Button ID="Button_ResetPwd"  CssClass="loginbutton" runat="server" Text="Reset Pin" Width="200px" OnClick="btnResetPwd_OnClick" Visible="true" />
         </asp:Panel>
     </h2>
</div>

Here is the register for the control.

<%@ Register Src="~/ScannerReset.ascx" TagPrefix="ctrl" TagName="ScannerReset" %>

And here is the part of ScannerReset.ascx code

<asp:panel id="pnl_textbox" runat="server">
     <asp:textbox id="txt_textbox" CssClass="logintextbox" runat="server" wrap="False" ontextchanged="txt_textbox_TextChanged"  Width="150px"/>
</asp:panel>

I try to reset DefaultButton to an asp.Button to a TextBox derived from ASCX, so that when user fill in the textbox and press Enter on keyboard it will press the "Button_ResetPwd" and do some action. The thing is, it will not proceed to not action and keep refreshing the page whenever I press Enter on keyboard.

I tried with JavaScript (keypress) but it's also not working. I just want to know how I can associate DefaultButton to a TextBox ASCX. Or if there is any other workaround using JavaScript that I can try. I also cannot use simple asp:Textbox because the ASCX is needed (it's a TextBox with barcode scanning ability).

I am pretty new with ASP.NET development and I am lost with this. I appreciate any help or feedback.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda