J
JV
If a control needs to execute some client-side script when the document is
loaded, it's easy enough to register a script. Using
RegisterStartupScript() you could emit a script that starts with "<SCRIPT
FOR=window EVENT=onload ...". Unfortunately, this will work only once.
Thus if there is any other script for window.onload (such as when you use
your control twice, for example) only the one that appears last in the HTML
will actually execute.
It's also possible to use RegisterStartupScript() to register some script
code that's not contained in a function so that it just runs toward the end
of the page load process, but at that point the DOM is not completely
finished being loaded, so the script can't do certain things yet.
Am I overlooking something simple? How would you handle this situation?
loaded, it's easy enough to register a script. Using
RegisterStartupScript() you could emit a script that starts with "<SCRIPT
FOR=window EVENT=onload ...". Unfortunately, this will work only once.
Thus if there is any other script for window.onload (such as when you use
your control twice, for example) only the one that appears last in the HTML
will actually execute.
It's also possible to use RegisterStartupScript() to register some script
code that's not contained in a function so that it just runs toward the end
of the page load process, but at that point the DOM is not completely
finished being loaded, so the script can't do certain things yet.
Am I overlooking something simple? How would you handle this situation?