Perform Specific Button click event when user press Enter key in Textbox

Put your form inside an asp.net panel control and set its DefaultButton attribute with your button ID. See the code below:

 

<asp:Panel ID="Panel1" runat="server" DefaultButton="Button1">
        <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
         <ContentTemplate>
            <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
            <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Send" />
             </ContentTemplate>
          </asp:UpdatePanel>
</asp:Panel>

Leave a comment