Monday, April 02, 2007

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 ...