Strange focus behavior on Firefox 3+

Apparently it seems as if Firefox has changed the way the focus is set on the page starting with version 3+.
When using the <yourcontrol>.Focus() method on the current behavior is that Firefox automatically scrolls the page till the "focused" element is in the very last row of the screen. This is really nerving, especially if you're using Ajax UpdatePanels. In that case you have that as soon as the asynchronous postback caused by the UpdatePanel returns, your page starts to jump around (if on the server-side you set the focus on some control).
I used the following piece of code inside some Helper class to solve the problem. The idea is basically to use the ScriptManager to register a JavaScript which is launched as soon as the postback comes back to the client.
public static void SetFocusByJavaScript(Page page, Control targetControl)
SetFocusByJavaScript(page, targetControl.ClientID);

public static void SetFocusByJavaScript(Page page, string clientID)
string uniqueScriptId = String.Concat("focusScript", clientID);
string scriptBody = String.Format("setTimeout(\"$get('{0}').focus();\", 100);", clientID);
ScriptManager.RegisterStartupScript(page, page.GetType(), uniqueScriptId, scriptBody, true);
By the way this would be a nice candidate for writing an extender method on the control class...Should be realizable in an easy way.



Your ad here?