Skip to main content

Add Client Script to codebehind c# ASP.NET

To register a js file in the codebehind - just use the "ClientScript.RegisterClientScriptInclude"

Page.ClientScript.RegisterClientScriptInclude("blockui", string.Format("{0}/{1}", SPContext.Current.Site.RootWeb.Url.ToString(), "Style%20Library/PitchIn/Scripts/jquery.blockUI.js"));


To add script tags, then build the string and pass the value:

string loadingimage = @"";

Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "loadingimg", loadingimage, false);

Comments