I have 3 buttons in a form. One of them is the submit button. How can I make it the default button to be clicked when I press the enter key. Is there a property for this?
+4
A:
There is a property for the form: defaultbutton.
<form runat="server" defaultbutton="myButton">
...
</form>
It is first time implemented in ASP.NET 2.0.
Biri
2008-12-30 09:13:33
+2
A:
Or you can do it in code - Page_load:
Page.Form.DefaultButton = btnSearch.UniqueID;
Whenever you press enter the btnSerach control will be used as default.
Kb
2008-12-30 09:52:44
+4
A:
Another helpful tip is that you can set the default button on asp:panel's too.
qui
2008-12-30 09:54:33
Thank you. Thank you. Thank you. It's been a horrific morning of debugging and now I'd like to have your children!
Iain M Norman
2009-02-25 11:22:24
Sounds painful :)
qui
2009-02-25 15:31:25
Wow, this saved me a ton of time. Thanks!
Matthew Doyle
2009-11-24 16:01:46