I’ve just fixed a strange bug I was having when comparing a web page in IE and Firefox. The page simply had a single textbox, and a button. By default, in accordance with W3C standards, both browsers will post-back to the server when the user hits <Enter> from within the textbox.
Just the behaviour I wanted, except that when the post-back occurs from IE, the button’s event handler does not get triggered on the server!! Very strange … but this article on 4guysfromrolla.com gives a great explanation.
Basically, IE does not post-back a fully serialised form if there is only one textbox on the page! The server does not know what triggered the post-back and so cannot call the correct server-side event handler. The workaround? … add another textbox to the form (but just make it hidden!).
This is true for IE6 and IE7 …
Update 5 APR 2008: An example would be nice, so this is what I used…
<asp:TextBox ID=”IEPostbackBugFix” runat=”server” style=”visibility:hidden;display:none;” />
Great Article. Question:In ASP.NET, It’s not enough to just make the visibility=false on the dummy ASP:textbox. The misfire will still occur.
Are you saying add an HTML textbox?
By: SadClowwwn on April 4, 2008
at 3:43 pm
It should not matter if it is an ASP.NET controlled text box or a manually added HTML one. It was a while since I researched all of this, but I found a code example, so I’ve updated the post so you can give that a go.
By: matthewtester on April 4, 2008
at 8:08 pm