Submit form when Enter is pressed
22,718
Solution 1
You set the forms default button:
<form id="Form1"
defaultbutton="SubmitButton"
runat="server">
Solution 2
Make it the default button of the form or panel.
Either one has a DefaultButton
property that you can set to the wanted button.
Comments
-
Jishnu A P almost 2 years
I have an aspx page with many buttons and i have a search button whose event i want to be triggered when user press enter. How can i do this?
-
Jishnu A P over 13 yearsBut the form that i use is in the master page!
-
m.edmondson over 13 yearsTry this Page.Form.DefaultButton = "Button1"
-
a2f0 almost 10 yearsI'd recommend looking into this as well, "this.Form.DefaultButton = this.ibRecalc.UniqueID;" stackoverflow.com/questions/3614797/…
-
Andrew Grinder over 9 years@dps comment works best when you have a master page that has its own form tags. You cannot put another form within a form.