Geeks With Blogs
.NET DAD .NET, once more...

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.



When contacted, Scott Mitchell, whom I consider a GURU in .NET, was grateful enough to cook up an article addressing this issue.

Posted on Wednesday, August 3, 2005 3:45 PM .NET | Back to top

Comments on this post: A Click of a Nightmare

No comments posted yet.
Your comment:
 (will show your gravatar)

Copyright © Rajeev Gopalakrishnan | Powered by: