views:

500

answers:

2

I have an ASP.Net page with a usercontrol on it. The submit button for the page is within the usercontrol. There is an ImageButton on the page itself (outside of the usercontrol). Whenever I hit the enter key to submit the form, it always executes the ImageButton click instead of the submit button within the usercontrol.

I'm using a MasterPage for the style, so the form is within that which rules out using the form's DefaultButton property.

+7  A: 

Put your controls inside a panel and set that panel's DefaultButton property.

Joel Etherton
This worked perfectly - thank you so much!
Aaron
+1 - Good answer
Mark Brittingham
Not that it affects this exact situation, but always needs clarification that the `DefaultButton` property doesn't work for the `LinkButton` control (in browsers other than IE).
bdukes
+1  A: 

Add focus on page load.

This example might help: http://www.webmasterworld.com/forum91/1611.htm

It sets the focus on submit button, but focus will be lost when you click a text field in the form.

Steven
+1 - might not be what Aaron was looking for but useful nonetheless.
Mark Brittingham