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.