More in this section

Forums / General Discussions / Load .js and .css files into custom user control

Load .js and .css files into custom user control

5 posts, 1 answered
  1. adi
    adi avatar
    5 posts
    Registered:
    17 Jul 2008
    27 Feb 2012
    Link to this post
    Hello
    I have a problem when trying to add some JavaScript libraries and CSS files into my ascx control. Using the classic declarations <script src="" type="text/javascript" /> or using 
    <sf:ResourceLinks ID="resourceLinks" runat="server">
        <sf:ResourceFile Name="~/Application/Backend/Content/js/jValidateForm.min.1.0.js"  />
    </sf:ResourceLinks>  
    doesn't work.
    My path to the js is root/Application/Backend/Content/js.
    Thank you
  2. Stanislav Velikov
    Stanislav Velikov avatar
    1113 posts
    Registered:
    18 Sep 2017
    27 Feb 2012
    Link to this post
    Hi,

     Load jquery or other scripts either from embedded resources or relative path is using javascriptembedcontrol.

    <%@ Register TagPrefix="sf" Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Web.UI" %>

    <sf:JavaScriptEmbedControl runat="server" ID="jQueryLink" ScriptEmbedPosition="Head"
            
    </sf:JavaScriptEmbedControl>
            
    <sf:JavaScriptEmbedControl runat="server" ID="jQueryUILink" ScriptEmbedPosition="Head"
            
    </sf:JavaScriptEmbedControl>
            
    <sf:JavaScriptEmbedControl runat="server" ID="JavaScriptEmbedControl6" Url="~/RTC_Scripts/series.js"
            
        ScriptEmbedPosition ="Head">
            
    </sf:JavaScriptEmbedControl>
            
    <sf:JavaScriptEmbedControl runat="server" ID="JavaScriptEmbedControl5" Url="~/RTC_Scripts/jquery.anythingslider.js"
            
        ScriptEmbedPosition="Head">
            
    </sf:JavaScriptEmbedControl>

    Greetings,
    Stanislav Velikov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. adi
    adi avatar
    5 posts
    Registered:
    17 Jul 2008
    27 Feb 2012
    Link to this post
    Unfortunately, the code you provided doesn't work ... it cannot find JavaScriptEmbedControl in Telerik.Sitefinity.Web.UI ... Thank you anyway for the reply

  4. Stanislav Velikov
    Stanislav Velikov avatar
    1113 posts
    Registered:
    18 Sep 2017
    01 Mar 2012
    Link to this post
    Hello,

     Here is the correct assembly:

    <%@ Register Namespace="Telerik.Sitefinity.Web.UI.PublicControls" Assembly="Telerik.Sitefinity" TagPrefix="sf" %>

    All the best,
    Stanislav Velikov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
    Answered
  5. adi
    adi avatar
    5 posts
    Registered:
    17 Jul 2008
    01 Mar 2012
    Link to this post
    Problem solved. Thank you
5 posts, 1 answered