+1-888-365-2779
Try Now
More in this section

Forums / Designing & Styling / How do I add an external javascript file to my custom masterpage?

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

2 posts, 0 answered
  1. Richard
    Richard avatar
    64 posts
    Registered:
    09 Oct 2012
    26 Sep 2012
    Link to this post
    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!
  2. Richard
    Richard avatar
    64 posts
    Registered:
    09 Oct 2012
    26 Sep 2012
    Link to this post
    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>
2 posts, 0 answered