Not sure about the problem but it could be loading elements ...
Perhaps you need to run your JS on the
document.ready event[
^].
The Page.RegisterStartupScript is sure enough to run at the end of the HTML but perhaps some JS is not yet loaded?
Try attaching to the event to be on the safe side.
Best, H