Embedded resource not working
Hi,
Im just running through the news rotator widget sample. When i run my website, I dont get any error messages as such, however the styles I defined in the embedded css file do not seem to be available to the page. When I look at the CSS which is being pulled in via SiteFinity, it is definitey trying to load my newsrotator.css embedded resource:
/Telerik.Web.UI.WebResource.axd?compress=1&_TSM_CombinedScripts_=%3b%3bNewsRotator%2c+Version%3d1.0.0.0%2c+Culture%3dneutral%2c+PublicKeyToken%3dnull%3aen%3a6a5b78dd-2e4e-45f3-82ea-635ac7466d01%3a6a5c2e6a%3bHi higgsy,
Have you added the css to AssemblyInfo.cs ?
[assembly: WebResource("Telerik.Sitefinity.Samples.Themes.Test.StyleSheet.css", "text/css", PerformSubstitution = true)]
Regards,
Ivan Dimitrov
the Telerik team
Hi Ivan,
Yes I have:
[assembly: WebResource("NewsRotator.Resources.newsrotator.css", "text/css", PerformSubstitution=true)]
I have also ensured the file is to Embedded resource.
Then in my template, I have:
<%@ Register Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Web.UI" TagPrefix="sitefinity" %>
<sitefinity:ResourceLinks runat="server">
<sitefinity:ResourceFile Name="NewsRotator.Resources.newsrotator.css" AssemblyInfo="NewsRotator.Rotator, NewsRotator" />
</sitefinity:ResourceLinks>
I can't seem to find a reasonable explanation as to why it is happening.
Thanks
higgsy
Hi Ivan,
The embedded resource is definitely being loaded, as the URL generated for it is:
/WebResource.axd?d=5g6LTy1saM854E3kCaXgjrzdfuXbDGvzyCRd1tDqUmhM9dLD8tvQmVRXz58LkAH_udKyYsGatto7HGhklQybtKeR1dOTWY0fRaCO6kUCDAGPcatov1i5YaKyWabP-Zs8NRRYALTPxL5r5Pan-0n2Tg2&t=634306084080469205
And I can view this url and see the contents of the CSS file. However, it just appears that when sitefinity is trying to load it and combine it, it cant do so.
Any ideas?
Thnaks
higgsy
Hello higgsy,
1.Set Static property to true. AssemblyInfo should contain a class from your assembly.
<sitefinity:ResourceLinks ID="ResourceLinks1" runat="server" UseEmbeddedThemes="true">
<sitefinity:ResourceFile Name="Telerik.Sitefinity.Samples.Resources.Layout.css" Static="true" AssemblyInfo="Telerik.Sitefinity.Samples.Reference, Telerik.Sitefinity.Samples" />
</sitefinity:ResourceLinks>
2. Layout.css should be "EmbeddedResource" and it has to be registered inside AssemblyInfo.cs
If 1 and 2 are met the class is add to a page.
Greetings,
Ivan Dimitrov
the Telerik team
Hi Ivan,
the "static" attribute did the job.
Still getting one strange result though, when I open my control designer I just get an empty screen (see screenshot).
I have marked my Rotator class with the controldesigner attribute:
[Telerik.Sitefinity.Web.UI.ControlDesign.ControlDesigner(typeof(RotatorDesigner))]
And my RotatorDesigner has the LayoutTemplateName string set:
class RotatorDesigner : ControlDesignerBase protected override void InitializeControls(GenericContainer container) base.DesignerMode = ControlDesignerModes.Simple; protected override string LayoutTemplateName get return "NewsRotator.Resources.RotatorDesigner.ascx"; protected override HtmlTextWriterTag TagKey get return HtmlTextWriterTag.Div; public override IEnumerable<ScriptReference> GetScriptReferences() var res = new List<ScriptReference>(base.GetScriptReferences()); var assemblyName = this.GetType().Assembly.GetName().ToString(); res.Add(new ScriptReference("NewsRotator.Resources.RotatorDesigner.js", assemblyName)); return res.ToArray(); Hi higgsy,
Check the browser console for javascript errors. The javascript is not properly initialized or there are some other errors.
Greetings,
Ivan Dimitrov
the Telerik team
Hi Ivan,
Thats what I originally thought, so i check the JS which has been loaded into the combined script:
/* START NewsRotator.Resources.RotatorDesigner.js */Type.registerNamespace("NewsRotator");NewsRotator.RotatorDesigner = function (element) NewsRotator.RotatorDesigner.InitializeBase(this, [element]);NewsRotator.RotatorDesigner.prototype = initialize: function () NewsRotator.RotatorDesigner.callBaseMethod(this, 'initialize'); , dispose: function () NewsRotator.RotatorDesigner.callBaseMethod(this, 'dispose'); , refreshUI: function () var data = this._propertyEditor().get_control(); jQuery("#RotatorWidth").val(data.Width); jQuery("#RotatorHeight").val(data.Height); jQuery("#RotatorItemWidth").val(data.ItemWidth); jQuery("#RotatorItemHeight").val(data.ItemHeight); jQuery("#RotatorDisplayTime").val(data.FrameDuration); jQuery("#RotatorNewsLimit").val(data.NewsLimit); jQuery("#RotatorNewsProviderName").val(data.ProviderName); , applyChanges: function () var controlData = this._propertyEditor().get_control(); controlData.Width = jQuery("#RotatorWidth").val(); controlData.Height = jQuery("#RotatorHeight").val(); controlData.ItemWidth = jQuery("#RotatorItemWidth").val(); controlData.ItemHeight = jQuery("#RotatorItemHeight").val(); controlData.FrameDuration = jQuery("#RotatorDisplayTime").val(); controlData.NewsLimit = jQuery("#RotatorNewsLimit").val(); controlData.ProviderName = jQuery("#RotatorNewsProviderName").val(); NewsRotator.RotatorDesigner.registerClass('NewsRotator.RotatorDesigner', Telerik.Sitefinity.Web.UI.ControlDesign.ControlDesignerBase);if (typeof (Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();/* END NewsRotator.Resources.RotatorDesigner.js */Hi higgsy,
Try making the RotatorDesigner public class. If the problem persists I will attach a sample!
Greetings,
Ivan Dimitrov
the Telerik team
Hi Ivan,
I can partially see what the problem is:
Using Firebug i looked at the following code, which I believe should be defining the content for the simple and advanced views:
<!-- 2010.3.1109.40 --><div id="ctl04_ctl00_simpleModeView" class="rmpHiddenView"> <!-- do nothing, designer will be automatically loaded --> <div id="ctl04_ctl00_ctl00"> <div class="sfContentViews"> <div id="RotatorOptions"> <h2> Fine tune your Rotator</h2> </div></div> </div> </div><div id="ctl04_ctl00_advancedModeView"> <div id="ctl04_ctl00_propertyGrid"> <div class="sfPropsToolsWrapper"><div id="expandCollapsePanel"> <a onclick="return false;" id="ctl04_ctl00_propertyGrid_ctl00_collapseAllButton" href="javascript:__doPostBack('ctl04$ctl00$propertyGrid$ctl00$collapseAllButton','')"> Collapse all </a> | <a onclick="return false;" id="ctl04_ctl00_propertyGrid_ctl00_expandAllButton" href="javascript:__doPostBack('ctl04$ctl00$propertyGrid$ctl00$expandAllButton','')"> Expand all </a></div><div id="breadcrumbDiv" style="display: none;"> <div id="ctl04_ctl00_propertyGrid_ctl00_breadcrumb"> <input id="ctl04_ctl00_propertyGrid_ctl00_breadcrumb_ClientState" name="ctl04_ctl00_propertyGrid_ctl00_breadcrumb_ClientState" type="hidden"> </div></div><div id="displayModesPanel"> <div id="ctl04_ctl00_propertyGrid_ctl00_propertyViewsToolbar" class="RadToolBar RadToolBar_Horizontal RadToolBar_Sitefinity RadToolBar_Sitefinity_Horizontal sfPropertyViews" style="z-index: 9000;"> <div class="rtbOuter"> <div class="rtbMiddle"> <div class="rtbInner"> <ul class="rtbUL"> <li class="rtbItem rtbBtn rtbChecked"><a title="Alphabetically" class="sfPropAlphabetically rtbWrap" href="#"><span class="rtbOut"><span class="rtbMid"><span class="rtbIn"><span class="rtbText">Alphabetically</span></span></span></span></a></li><li class="rtbItem rtbBtn "><a title="Categorized" class="sfPropCategorized rtbWrap" href="#"><span class="rtbOut"><span class="rtbMid"><span class="rtbIn"><span class="rtbText">Categorized</span></span></span></span></a></li> </ul> </div> </div> </div><input id="ctl04_ctl00_propertyGrid_ctl00_propertyViewsToolbar_ClientState" name="ctl04_ctl00_propertyGrid_ctl00_propertyViewsToolbar_ClientState" type="hidden"> </div></div></div><div class="sfPropertiesListWrapper"> <ul id="screens"> <li id="level0" class="screen"> <ul id="propertyGridLevel0"></ul> </li> </ul></div><ul id="ctl04_ctl00_propertyGrid_ctl00_propertyGridBinder_ctl00_clientTemplate" class="sys-template"> <li sys:class=" 'sf_item' + CategoryNameSafe"> <div class="sf_categoryElement" style="display: none;"> <a id="categoryNameLink" class="sf_categoryLink" href="#">CategoryName</a> </div> <div sys:class=" 'sf_propertyElement ' + ElementCssClass "> <label for="PropertyValue">PropertyName</label> <input id="PropertyValue" class="sf_propertyInput" sys:value="PropertyValue" type="text"> <a class="sf_complexProperty selectCommand sfChange sfLinkBtn" href="#" style="display: none;"><strong class="sfLinkBtnIn">PropertyName</strong></a> </div> </li> </ul><div id="ctl04_ctl00_propertyGrid_ctl00_propertyGridLoadingPanel" class="RadAjax RadAjax_Sitefinity" style="display: none;"> <div class="raDiv"> Loading... </div><div class="raColor"> </div> </div><script type="text/javascript"> $("body").addClass("sfSelectorDialog");</script> </div> </div><input id="ctl04_ctl00_modesMultiPage_ClientState" name="ctl04_ctl00_modesMultiPage_ClientState" type="hidden"> public class RotatorDesigner : ControlDesignerBase protected override void InitializeControls(GenericContainer container) base.DesignerMode = ControlDesignerModes.Simple; Hi Ivan,
I found the problem - what a nightmare it was. This was the error:
NewsRotator.RotatorDesigner.InitializeBase(this, [element]);