How to included an embedded js file
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
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
>
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
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