Monday, October 15, 2012

How to add external script(JS) on page in sharepoint 2010

Here i will explain how to import the external java script file into specified share point site web page.To add the file reference by using  a class "script link" which will be used to request scripts by the time of page rendered in share point 2010.We will add the reference both client side and sever side to page using this below piece of code.
Client Side:
<SharePoint:ScriptLink ID="sl" name="/_layouts/Jscripts/testadd.js" runat="server" Defer="false"/>
Server Side:
By using the below method we can access script on server side.The Register method contains the there variable which are page name,script file name and localizable value .
ScriptLink.Register(this.Page, "/_layouts/Jscripts/testadd.js", false);


No comments: