Difference between Page.ClientScript.RegisterStartupScript and ClientScript.RegisterClientScriptBlock ?
The main difference between the two is that, RegisterStartupScript places the script at Bottom of
page and RegisterClientScriptBlock at the Top of
the page.
So what’s the big deal in both these scenarios.
Well, the main use of these two depends upon the situation for which we want to
use.
Take an
example of a javascript function that populates a Textbox using a javascript
function when a page is loaded. If you use the RegisterClientScriptBlock method,
the javascript function will give an error. This is because your script is
placed at the top of the page when it was loaded (when the textbox was not even
created). So how can it find the textbox and populate the values. Sp in this case
RegisterStartupscript should be used.
So use of any of the above function depends upon
type of script.