How to included an embedded js file

Posted by Community Admin on 03-Aug-2018 13:59

How to included an embedded js file

All Replies

Posted by Community Admin on 18-Dec-2011 00:00

Hello,

I am asking about how to embed a js file in a custom widget, I am following the steps below however I got the error attached in "Error.png":
1- Set the "BuildAction" of the js file is set to "EmbeddedResource" (please review "JsBuildAction,png")
2- Add the registration of the js file in the AssemblyInfo.cs of the web application 

[assembly: System.Web.UI.WebResource("SitefinityWebApp.ImageControl.jquery.prettyPhoto.js", "text/javascript")]

3- add a link to the js file from my custom widget

<sitefinity:ResourceFileName="SitefinityWebApp.ImageControl.jquery.prettyPhoto.js"AssemblyInfo="SitefinityWebApp" />


Am I missing something?

Thanks, 
Amr



Posted by Community Admin on 21-Dec-2011 00:00

Hello Amrelsayed,

Can you try to make the registration as bellow:

<sf:ResourceLinks id="resourcesLinks1" runat="server" UseEmbeddedThemes="true">
  <sf:ResourceFile Name="SitefinityWebApp.ImageControl.jquery.prettyPhoto.js" AssemblyInfo="SitefinityWebApp.ImageControl, SitefinityWebApp"/>
</sf:ResourceLinks>

Where the highlighted part is the class name of the control in which you are going to use the extension.

All the best,
Radoslav Georgiev
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 04-Jan-2012 00:00

I am trying to use the ResourceLinks control to embed a JS file a CSS file along with including the built-in JQuery. I think I have all the steps correct, but no go. Looks like an issue with Sitefinity maybe. Here is what I did:

 1) Set the build action to embedded for the js and css files

2) Add this to AssemblyInfo.cs:

[assembly: WebResource("SitefinityWebApp.Widgets.Ads.Resources.JavaScript.plugin.js", "text/javascript")]

[assembly: WebResource("SitefinityWebApp.Widgets.Ads.Resources.Stylesheets.internAds.css", "text/css")]

3) Added the correct resource links format to the template files:

<sf:ResourceLinks ID="resourcesLinks" runat="server">

    <sf:ResourceFile JavaScriptLibrary="JQuery" />

    <sf:ResourceFile

        Name="SitefinityWebApp.Widgets.Ads.Resources.JavaScript.plugin.js"

        AssemblyInfo="SitefinityWebApp.Widgets.Ads.InternAd, SitefinityWebApp" />

    <sf:ResourceFile

        Name="SitefinityWebApp.Widgets.Ads.Resources.Stylesheets.internAds.css"

        AssemblyInfo="SitefinityWebApp.Widgets.Ads.InternAd, SitefinityWebApp" /> </sf:ResourceLinks>

Note that I am including the widget right in the SitefinityWebApp project instead of using a compiled widget.

Your help will be really appreciated.

Thanks,

G

Posted by Community Admin on 05-Jan-2012 00:00

Hello,

Can you try setting the UseEmbeddedThemes property on ResourceLinks control to true? Also for the CSS file, please set the Static property to true.

All the best,
Radoslav Georgiev
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

This thread is closed