Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

How to make a button the default button on enter on an ASP.NET form

0.00/5 (No votes)
20 Jul 2011 1  
By putting your intended content in a division as bellow, the button you set as default button will be hit when you hit enter button on any element which is in the division.
XML
<div onkeypress="return WebForm_FireDefaultButton(event, '<%= btnSubmit.ClientID %>')">
 <!-- put your form cntrols here -->
 
 <asp:Button ID="btnSubmit" runat="server" Text="Submit" />
</div>

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here