Is there any way to manageme Submit buttons behaviour?
For example:
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="up1" runat="server">
<ContentTemplate>
<asp:TextBox runat="server" ID="tb1" />
<asp:Button runat="server" ID="btnSubmit1" UseSubmitBehavior="true" />
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="up2" runat="server">
<ContentTemplate>
<asp:TextBox runat="server" ID="tb2"> />
<asp:Button runat="server" ID="btnSubmit2" UseSubmitBehavior="true" />
</ContentTemplate>
</asp:UpdatePanel>
</form>
If we are on focus on “tb2”, I wish that “btnSubmit2” will have control over “Submit” behaviour (e.g. pressing enter). we are on focus on “tb1”, I wish that “btnSubmit1” will have control over “Submit” behaviour (e.g. pressing enter).
I presume it should be implemented in the ASP.NET infrastructure, and if not, what is the best way to implement management of Submit buttons behaviour in ASP.NET 3.5 or ASP.NET 4.0?
Thanks in advance.
Panels have the
DefaultButtonproperty, see MSDN. You could wrap your controls in a Panel, and set that property to the Button you want to submit the form by.