Load .js and .css files into custom user control

Posted by Community Admin on 03-Aug-2018 10:49

Load .js and .css files into custom user control

All Replies

Posted by Community Admin on 27-Feb-2012 00:00

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

Posted by Community Admin on 27-Feb-2012 00:00

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

Posted by Community Admin on 27-Feb-2012 00:00

Unfortunately, the code you provided doesn't work ... it cannot find JavaScriptEmbedControl in Telerik.Sitefinity.Web.UI ... Thank you anyway for the reply

Posted by Community Admin on 01-Mar-2012 00:00

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

Posted by Community Admin on 01-Mar-2012 00:00

Problem solved. Thank you

This thread is closed