Background | collection | script | Execute #region Declaration
//----------------------------------------------------------------------
//
//
Author: Nick.lee
//
Complete JavaScript script collection in. NET Background
//
Boyorgril@msn.com
//
//----------------------------------------------------------------------
#endregion
#region registering a collection of JavaScript script functions in. net
<summary>
Function: Registers a script language on the client and emits the script before the Page object's <form runat= server> element's closing tag
Entering: Page objects in page pages
Script wants to register JavaScript scripts that need to include tags such as <script language=javascript>
Output: None.
</summary>
public static void RegisterStartupScript (System.Web.UI.Page page,string script)
{
String strkey;
int i;
Register key for script block
Strkey=system.datetime.now.tostring ();
Loop until you find a key that has not been registered.
for (i=0;i<100;i++)
if (!page. IsStartupScriptRegistered (Strkey+i.tostring ()))
Break
Page. RegisterStartupScript (strkey+i.tostring (), script);
}
<summary>
Function: Registers a script language on the client and emits the script immediately after the Page object's <form runat= server> element's start tag
Entering: Page objects in page pages
Script wants to register JavaScript scripts that need to include tags such as <script language=javascript>
Output: None.
</summary>
public static void RegisterClientScriptBlock (System.Web.UI.Page page,string script)
{
String strkey;
int i;
Register key for script block
Strkey=system.datetime.now.tostring ();
Loop until you find a key that has not been registered.
for (i=0;i<100;i++)
if (!page. IsClientScriptBlockRegistered (Strkey+i.tostring ()))
Break
Page. RegisterClientScriptBlock (strkey+i.tostring (), script);
}
#endregion
#region execute a collection of script modules
<summary>
Function: Executes a client-side script language that emits the script immediately after the Page object's <form runat= server> element's start tag
Entering: Page objects in page pages
Script to execute JavaScript scripts
Output: None.
</summary>
public static void Executeblock (System.Web.UI.Page page,string script)
{
String Strscript;
String strkey;
int i;
The contents of the script block
strscript= "<script language=javascript>\n";
strscript+= "" +script+ ";";
strscript+= "</script>";
Register key for script block
Strkey=system.datetime.now.tostring ();
Loop until you find a key that has not been registered.
for (i=0;i<100;i++)
if (!page. IsClientScriptBlockRegistered (Strkey+i.tostring ()))
Break
Page. RegisterClientScriptBlock (Strkey+i.tostring (), strscript);
}
<summary>
Function: Executes a client-side script language that emits the script before the Page object's <form runat= server> element's closing tag
Entering: Page objects in page pages
Script to execute JavaScript scripts
Output: None.
</summary>
public static void Executestartup (System.Web.UI.Page page,string script)
{
String Strscript;
String strkey;
int i;
The contents of the script block
strscript= "<script language=javascript>\n";
strscript+= "" +script+ ";";
strscript+= "</script>";
Register key for script block
Strkey=system.datetime.now.tostring ();
Loop until you find a key that has not been registered.
for (i=0;i<100;i++)
if (!page. IsStartupScriptRegistered (Strkey+i.tostring ()))
Break
Page. RegisterStartupScript (Strkey+i.tostring (), strscript);
}
#endregion
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.