Consider this snippet of code…
<form runat="server">
<asp:TextBox runat="server" ID="TextBoxOne" />
<asp:Button runat="server" ID="SubmitOne" OnClick="ButtonOne_Click" />
<hr />
<asp:TextBox runat="server" ID="TextBoxTwo" />
<asp:Button runat="server" ID="SubmitTwo" OnClick="ButtonTwo_Click" />
</form>
I want to group these two sets of controls.
When the user presses ENTER, having filled out TextBoxOne; the ButtonOne_Click event fires. And when the user has typed something into TextBoxTwo and presses enter; the ButtonTwo_Click event gets fired.
The way you would normally do this, is to have form elements surround each of the groups. But this is not possible in ASP.NET. And short of doing some “has-focus”-logic in JavaScript, I’m all out of ideas.
You can use an
<asp:Panel runat=server DefaultButton="SubmitOne">around the pair.