Load .js and .css files into custom user control - General Discussions - General Discussions - Progress Community
 General Discussions

Load .js and .css files into custom user control

  • Load .js and .css files into custom user control
  • 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
  • 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
  • Unfortunately, the code you provided doesn't work ... it cannot find JavaScriptEmbedControl in Telerik.Sitefinity.Web.UI ... Thank you anyway for the reply

  • 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
  • Problem solved. Thank you