Monday, June 06, 2005

A Click of a Nightmare

One of my colleagues came to me with a problem: He wanted to make the click event of button in his form to be activated when anyone pressed ENTER key. I said it works by default and it needs no tweaking. To my surprise, he showed me that it is not.

Then I went back to the form that I had developed and showed him that I did no extra coding to make it work. The click event just got raised when I hit the ENTER key. He was surprised too.

It would have been easy to implement his requirement with some JavaScript programming, but I wanted to find out the reason behind this contradictory behavior. The only difference between my form and his was that mine had more than one input controls (such as textbox and dropdownlists) and his had only one textbox. Well, after going through a lot of sane thoughts, I did one last insane activity: I added one more textbox control to his form. And it all worked: the click event got raised at the hit of the ENTER key.

I have no clue why this is happening. Do you have any?

1 comment:

  1. Well, straight from the horse's mouth: