Saturday 20 August 2011

Using Javascript file in a visual webpart Sharepoint 2010


If you want to reference a Javascript file in your Visual webpart in sharepoint, you can either add them in your solution under one of the sharepoint mapped folders or you can reference them when they are loaded in some library or in Layouts -> Styles folder

// Referring External Javascript
ClientScriptManager cs = Page.ClientScript;

// Include the required javascript file.
if (!cs.IsClientScriptIncludeRegistered("jsfile"))
cs.RegisterClientScriptInclude(this.GetType(), "jsfile", "/_layouts/1033/styles/jsfile.js");

Ads by Google

No comments:

Post a Comment