Challenges:
As I mentioned in my previous post, I fixed the issue of hitting enter key on an ASP.NET page with a single textbox and submit button. But now new issue occurred: I could not use the Enter key on other button web controls. Whenever I hit the Enter key in the web form, the onClick event of the search button fires not the other submit buttons. I know I am Master page and the search button has been included in every page based on this master page, and the search button is in the first button web control position.
Trouble Shootings:
OK, the first thing came to my mind to resolve the issue above was to use the new DefaultButton properties in ASP.NET 2.0 form or panel controls. But since I am using Masterpage, when I put defaultButton=”btnSubmit” in master page or put the following code in my Page_load event
Page.Form.DefaultButton = “btnSubmit”
I got the following error:
Server Error in ‘/MyApplication’ Application.
The DefaultButton of ‘form1′ must be the ID of a control of type IButtonControl.Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: The DefaultButton of ‘form1′ must be the ID of a control of type IButtonControl.
Continue reading ‘How to set the DefaultButton in a Page Based on ASP.NET Master Page’
Blog Comments