Enter Not Working in IE

Posted In Microsoft, Tutorials - By NitiN Kumar Jain On Sunday, December 20th, 2009 With 0 Comments






Pin It


Recently, I noticed a weird thing when one of my aspx page did not post back the command button click event when <enter> on the keyboard was hit having focus on a textbox.

Actually, I have an aspx page in my Dot Net project and it has only 2 controls on it. One is textbox and another one is submit button to search the content.

The HTML code of the page looks like:



(I have skipped the html and other common tags for easy reading.)

Now, ideally, when the user keys in some value in the textbox and hit <enter> on the keyboard then the submit button click should be executed, but it does not. Though the page is posted back but nothing happens.

Strange thing is that the problem occurs only when there is a single textbox control on the page. If I add another textbox on the page then it works like a butter.




I am running .Net framework 2.0 and VS2005.

After googling it for a while, I discovered that it is not a problem with Dot Net framework or studio but a known problem with browser IE.

Basically, IE doesn’t send the name/value pair on postback when only one textbox exists. However, it does for >1 textboxes.

So, to make it run we can add a hidden textbox as a workaround and it works good then. Read an article on 4GuysFromRolla.

Strange but true. Known bug but nothing has been done to fix it yet.