I have an asp.net page that loads some JavaScript scripts.
One of those scripts loads some controls into the page appending them to the body in the window.onload
event.
I need to inject a script via code behind to call a method of the scripts that depends on the controls created in the window.onload
. This doesn't work because every call I make it's always to early and the controls are not created at the moment. If I call it by, for instance, onclick
in an hyperlink it works because the controls were already created in the onload
.
So:
<script type="text/javascript" src="/Scripts/somefile.js"></script>
addEvent(window, "load", blabla);
- the js above prepares some controls to be appended to the body on the onload eventIn the code behind I try to write a script to the page by
this.Page.ClientScript.RegisterStartupScript
orthis.Page.ClientScript.RegisterClientScriptBlock
or whatever way that should call a method on the .js above, which depends on the control loaded on theonload
event. This step fails because the control is not in the DOM yet.
Any suggestion on how make the call after the window.onload
event?