OrientationChanged is a mess.

Subject says it all… When a mobile device orientation is changed, two events get sent to the server, a resized (page) and an orientation changed (session). Problem is that these don’t necessarily arrive in a predictable order. And responding to both of them by rearranging controls can often end up arranging controls for the wrong orientation when the whole sequence is done. This is because the response to the second event could be received by and processed by the browser BEFORE the response to the first. That’s another problem we have so long as communication isn’t serialized.

Ideally, instead of sending two events, the browser would send the page size and orientation in a single event, then for compatibility, the framework server side could dispatch in a predictable order. If a browser doesn’t have window.orientation, just send 0 for that parameter. Not a fan of telling you guys how to do stuff, but the current implementation is less than useless.

A work-around is to ping the client in WebPage.Resized event handler, then initiate the server side repositioning of controls in response to that ping. How to ping? Custom web control. And typically 1/2 second latency before page can respond with a correct control arrangement. I’ll have this, plus a fix for Firefox mobile in the next Web Essentials.