Reputation: 4737
I have a few submit buttons in my ASP.NET page. Everything works fine, but when a user hits enter button always the first submit button works. I want to fire each submit button with corresponding fields but cannot have multiple forms. Is it possible to group them without using forms?
Upvotes: 3
Views: 4900
Reputation: 3125
Please use DefaultButton
property like this
<asp:Panel runat="server" DefaultButton="bt1">
<asp:TextBox runat="server" />
<asp:Button id="bt1" Text="Default" runat="server" />
</asp:Panel>
Please refer here :- ASP.NET DefaultButton Property
Upvotes: 5
Reputation: 460158
You don't need forms, just wrap the related controls in their own panels and use the Panel.DefaultButton
property.
Use the
DefaultButton
property to indicate which button gets clicked when the Panel control has focus and the user presses the ENTER key. TheDefaultButton
can be set to the identifier for aButton
control or any control that implements theIButtonControl
interface except aLinkButton
control.
Upvotes: 5