asp.net onClick not executing

I am filing this in the category of WTF (What Terrible Functionality). 

We have all created forms with many different input controls that post back information we then process in some way.  Our users have come to expect that when they hit enter while filling out the form that it will trigger the submission of the form, and we usually do the processing through the onClick event of the submit button. 

I was creating a very simple form 1 textbox and a button that was to be used for a search page for an Intranet site.  During testing I discovered that sometimes this worked just fine and other times it didn’t work at all.  I could not figure out from users descriptions what they were doing differently.  I started paying special attention to the testers and how they were submitting the search criteria.  One user would type the search string then press tab, highlighting the submit button then press enter.  Another user would type the search criteria then with the mouse click the submit button.  It worked properly for both of these users.  But, one user would enter the search criteria then with the cursor still in the text box would hit enter.  It wouldn’t work.

This is an issue with the way that IE submits form data in the special circumstance of one textbox control on a form and the user pressing Enter while the textbox has focus.  4 Guys from Rolla have an excellent article that explains this behavior Enter and the Button Click Event.  Basically, IE does not submit the buttonID – Value pair for the submit button in this special circumstance.  4 Guys from Rolla offer a workaround of adding a second textbox and hiding it.

I think Microsoft, if they are aware, need to re-program this functionality in IE to always submit the buttonID – Value pair.  Other browsers work this way so its not impossible.

5. February 2009 13:41 by Duane | Comments (1) | Permalink

Comments

Comments are closed