// Add a script at the top of the page
If (! Page. ClientScript. IsClientScriptBlockRegistered ("myscriptKey") // you can determine whether a ScriptBlock with the same key value already exists. //
{
String myScript = @ "function AlertHello () {alert ('Hello xuanhun !! ');} "; // Script content
Page. ClientScript. RegisterClientScriptBlock (this. GetType (), "myscriptKey", myScript, true );
}
// Add a script at the bottom of the page
If (! Page. ClientScript. IsStartupScriptRegistered ("footscriptkey "))
{
String CallScript = @ "AlertHello ();";
Page. ClientScript. RegisterStartupScript (this. GetType (), "footscriptKey", CallScript, true );
}
// Add a reference to the js File
If (! Page. ClientScript. IsClientScriptIncludeRegistered ("incluedeKey "))
{
String shortdescript = @ "/js/ShowHello. js ";
Page. ClientScript. RegisterClientScriptInclude ("includeKey", IncludeScript );
}