Default Enter Button - June 2011
One of my clients repeatedly used 'Enter' to login after entering their user name and password rather than using the mouse to click a 'Login' button. I wondered if there was a way to force the login event to fire when the Enter key was pressed. I searched the web and found several suggestions. A web form or Asp.Net panel accepts attribute 'defaultbutton'. I did some testing - it works. So it becomes the June 2011 Tip-of-the-Month.
I published the application on the web. Click here to run the demo application.
The Asp.Net, VB.Net, VS/2008 project DefaultButton consists of two forms. The forms:
Press 'Enter' to fire the Login button event which redirects to the next page.
In this example the attribute is part of the form definition in the aspx page.
The user name and password are passed in a query string.
Press 'Enter' to return to the first page.
In this example the attribute is added in the CodeBehind page.
A web 'runat=server' Form or Asp.Net Panel accepts attribute defaultbutton. This demo uses the Form attribute with both pages. I use the panel attribute in my production application.
Download the source code by clicking on the zipped file name. Click here to run the demo application.
Download - Source Zipped File Size VS/2008 VB.Net, ASP.Net Solution DefaultButton.zip 99K
Previous Tip Tip Index Next Tip