Here are two of these methods :
Page.ClientScript.RegisterStartupScript(Type, String key, String script)
Page.ClientScript.RegisterClientScriptBlock(Type, String key, String script)
The “Type ” & “Key” pair distinguish between the different registered script. So you can’t register two script having both same type & key pair. The above two methods do the same thing with a basic difference that specify where to
use these functions.
1.RegisterClientScriptBlock() method add the script before the controls are renderd in the page. So the scripts we are registered can’t acess the controls inside the page.
e.g : var name = document.getElementById(‘txtName’); //will not work as excepted.
2.RegisterStartupScript() method add the script before the end of body tag after all the controls are rendered in the browser. So the registered script can acess the controls inside the page .
e.g : var name = document.getElementById(‘txtName’); //will work fine.
This above two methods have some limitations like we can’t add any script code after certain control render in the page.Other than this two above methods, there is some other way by which you can add some script code just after any control rendered in the browser dynamically . For that we have to use Literal or Label at the place where we want to add the script in the page. And we can add the script as their “text” property dynamically which will help us to execute any script .