I encountered a strange bug today while working on a login page in .NET. This page differed from your run-of-the-mill login page by having the user select their username and then enter their password, so only had one text field on the page.
The bug meant that when the user pressed enter after typing in their password to submit the form, although the form was submitted, the
SubmitButton_Click event that is set to trigger with the submit wasn’t evoked. Clicking the button itself worked, but trying to press enter anywhere on the form (except with the submit button selected) didn’t.
Even wrapping the content around a Panel and setting the
DefaultButton property on that to the submit button didn’t work. It turns out that Internet Explorer won’t evoke the
SubmitButton_Click event when there is only one textbox on the form, even if it’s explicitly set as the default button.
The solution is to create an empty textbox and set it to be invisible through CSS:
<asp:TextBox ID="TextBox1" runat="server" Style="display:none;"> </asp:TextBox>
Note that you can’t set its
Visible property to
false as that won’t render the textbox at all and you’ll still have the same problem.
Obviously, this is not the ideal solution to the problem, and hopefully this bug will be fixed in Internet Explorer 8. However for now, until I find a better fix, this is the only solution that works around this bug.