views:

998

answers:

1

I have a form that I want to submit when the user presses the enter key. It works fine in Firefox, but not in IE. It is basically the same issue as this, except that I am not allowed to use any JavaScript: http://stackoverflow.com/questions/270494/enter-button-does-not-submit-form-ie-only-asp-net

Unfortunately it looks like ASP.NET uses JavaScript to process the button postback. Is there a way around this issue that doesn't rely on JavaScript?

+3  A: 

The fix for this is what was listed in the bottom of the page of your linked post. IE needs to have an additional form field for some reason for this to work. I have used this in many projects, and it gets around the bug. Just add the following.

<!-- Fix for IE bug submit on pressing "Enter") -->
<div style="display:none">
            <input type="text" name="hiddenText"/>
</div>
Mitchel Sellers
Wait, does that *stop* the form from being submitted in non-IE browsers? OR does it enable submit in IE on [Enter]?
Crescent Fresh
I believe it fixes the submit problem. There is more information here:http://blog.richardszalay.com/2006/07/workaround-hitting-enter-to-submit.html
Jon Tackabury
It fixes IE and has NO effect on other browsers. (FF, Opera, Safari)
Mitchel Sellers