I had some fun this weekend with ASP.Net 2.0 Master pages and submit buttons when pressing Enter key. The catch here is that with the introduction of Master pages there's only one form per page which is specified in the master page.
UI simplicity for users has been pressing the Enter key when they wanted to submit the form data.
In older versions of ASP(.Net) you could put any number of forms on the page. The only rule was that they couldn't be nested. When you were in a form and you pressed Enter the browser used the submit button of that form and submited the form. (I won't be going into how browsers did or didn't implement this)
Because ASP.Net with Master pages can have only one Form with runat="server" tag and multiple forms are impossible this was solved in a very nice way.
Both Form and asp:Panel have a property called DefaultButton. The value of this property has to be set to the ID of the button you want to be clicked when the user presses Enter.
In my case I have a search on the master page and so the DefaultButton is set in the Form tag to the value of the "Search" button ID.
I have a form that has to be submitted to save data in the child page so i wrap up the content in asp:Panel control and set it's DefaultButton to my "Save" button's ID.
It works like a charm.
These are examples of use. I've omitted some attributes like OnClick handlers etc.
<!-- Master page -->
<form id="frmMaster" runat="server" defaultbutton="btnSearch">
<!-- Other input controls -->
<asp:Button ID="btnSearch" runat="server" Text="Search" />
<asp:ContentPlaceHolder ID="ContentBody" runat="server">
</asp:ContentPlaceHolder>
</form>
<!-- Child page -->
<asp:Content ID="content" ContentPlaceHolderID="ContentBody" runat="Server">
<asp:Panel ID="Panel1" runat="server" Width="100%" DefaultButton="btnSave">
<table>
<!-- Other input controls -->
<tr>
<td>
<asp:Button ID="btnSave" runat="server" Text="Save" />
</td>
</tr>
</table>
</asp:Panel>
</asp:Content>