Created
August 20, 2013 23:55
-
-
Save monyskynet/6288848 to your computer and use it in GitHub Desktop.
Register JavaScript in a page
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Define the name and type of the client script on the page. | |
String csName = "ButtonClickScript"; | |
Type csType = this.GetType(); | |
// Get a ClientScriptManager reference from the Page class. | |
ClientScriptManager cs = Page.ClientScript; | |
// Check to see if the client script is already registered. | |
if (!cs.IsClientScriptBlockRegistered(csType, csName)) | |
{ | |
System.Text.StringBuilder csText = new System.Text.StringBuilder(); | |
csText.Append("<script type=\"text/javascript\"> { }"); | |
cs.RegisterClientScriptBlock(csType, csName, csText.ToString()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment