How do I add an external javascript file to my custom masterpage? - Front- & Back-End Development - Front- & Back-End Development - Progress Community
 Front- & Back-End Development

How do I add an external javascript file to my custom masterpage?

  • How do I add an external javascript file to my custom masterpage?
  • I'm actually trying to add a javascript file that my custom masterpage will load. How do I go about adding this? I know I could add a javascript widget within the CMS admin but I'd prefer to have it referenced from the masterpage.

    I got the BlueMasters theme and am altering it. I noticed that it doesn't actually reference the stylesheet in the head. The stylesheet is in the App_Themes>BlueMasters>Global 
    How does Sitefinity know where the stylesheet is? Would a .js file be loaded in the same way? 

    Thanks for you help!
  • Ok I've answered my own question as far as adding a Javascript file. You add this code to your user control or masterpage.

    <%@ Register Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Web.UI" TagPrefix="sf" %>
    <sf:ResourceLinks ID="resourcesLinks" runat="server">
        <sf:ResourceFile JavaScriptLibrary="JQuery" />
    </sf:ResourceLinks>
    You could replace JQuery with MooTools or Prototype.

     or its possible to add your own external javascript file

    <%@ Register Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Web.UI" TagPrefix="sf" %>
    <sf:ResourceLinks ID="ResourceLinks1" runat="server">
        <sf:ResourceFile Name="~/Scripts/myJavascript.js" />
    </sf:ResourceLinks>