Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

226
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!