How to use the js script for background registration in ASP.NET
This article mainly introduces the ASP.NET background registration js script how to use, the article introduces in great detail, has a certain reference value, interested friends must read it!
Use Page.ClientScript.RegisterClientScriptBlock and Page.ClientScript.RegisterStartupScript: the difference:
1. Use Page.ClientScript.RegisterClientScriptBlock
C # code
The copy code is as follows:
Protected void Page_Load (object sender, EventArgs e)
{
String myScript = @ "function AlertHello () {alert ('Hello ASP.NET');}"
Page.ClientScript.RegisterClientScriptBlock (this.GetType ()
"MyScript", myScript, true)
}
The running results are as follows:
The copy code is as follows:
Adding JavaScript