1. isstartupscriptregistered: indicates whether the script is enabled for the object.
2. isclientscriptblockregistered: indicates whether the client script block is registered.
3. isclientscriptincluderegistered: indicates whether the object is registered with a client script.
Example 1:
String info = "<SCRIPT> alert ('Are you good? '); </SCRIPT> ";
// Determine whether the event is registered. Write to the region: <body >---- <SCRIPT> </body>
If (! Page. clientscript. isstartupscriptregistered ("test "))
{
// Dynamically register and execute JavaScript
Page. clientscript. registerstartupscript (this. GetType (), "test", Info );
}
Example 2:
Aspx file:
Name: <input id = "txtusername" type = "text"/>
<Input id = "btnsubmit" type = "button" value = "OK" onclick = "salert (txtusername. Value)"/>
CS file:
String info = "function salert (username) {alert ('your name: '+ username )}";
// Determine whether test has been registered
If (! Page. clientscript. isclientscriptblockregistered (this. GetType (), "test "))
{
// Dynamically register Javascript
Page. clientscript. registerclientscriptblock (this. GetType (), "test", info, true );
}
Example 3:
Aspx file:
Name: <input id = "txtusername" type = "text"/>
<Input id = "btnsubmit" type = "button" value = "OK" onclick = "salert (txtusername. Value)"/>
JScript. js
Function salert (username)
{
Alert ("Your name" + username );
}
CS file:
// Determine whether test has been registered
If (! Page. clientscript. isclientscriptincluderegistered (this. GetType (), "test "))
{
// Dynamically register Javascript
Page. clientscript. registerclientscriptinclude ("test", "jscript. js ");
}