The code is ok, I would only think that there is a
javascript error
before the focus scripts executes. And that error
could come up because
you set onload="focus()" in the body tag.
So, that's not necesary if you're using
RegisterStartupScript. just
remove the onload event handler.
A way of debug this is checkin the View Source in
the browser. You can
see if the js was generated or not in appropiate
format.