Return to TextBox, losing focus
If you want to do a postback when the TextBox loses focus (by pressing Enter , Tab or moving the focus to another control), set the AutoPostBack property to TextBox true.
After writing something in the TextBox and removing the focus, you will receive a postback. I believe, however, that this can be enhanced not only by pressing Enter. Additional information about MSDN: http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.textbox.autopostback.aspx .
Return by simulating the submit button Press the Enter button
If you want to postback only when you press enter, you can add a Button to the page and place it using the TextBox in the same Panel control. Then you must set the Panel property to DefaultButton . When you click the TextBox button (or any other control in the Panel ), when you click the button, press the "Enter" button.
So your code might look like this (code has not been tested):
... <asp:Panel ID="grouppingPanel" runat="server" DefaultButton="btnSubmitDomain"> <asp:TextBox ID="txtDomain" runat="server" ToolTip="Network domain user is associated." /> <asp:Label ID="lblRqdDom" runat="server" Text="required" CssClass="noshow" ></asp:Label> <asp:Button ID="btnSubmitDomain" runat="server" Text="GO" OnClick="btnSubmitDomain_Click" /> </asp:Panel> ...
You can find more information about this here: http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.panel.defaultbutton.aspx .
If you have any problems applying any of these solutions or further questions, let me know.
source share