More in this section

Forums / General Discussions / Embedded resource not working

Embedded resource not working

11 posts, 0 answered
  1. higgsy
    higgsy avatar
    336 posts
    Registered:
    05 Aug 2010
    14 Jan 2011
    Link to this post
    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%3b

    But within the body of that css it says:

    /* START */
    I did set EnableScriptCombine="false" but hat made no difference.

    Any help pelase?

    Thanks
    higgsy
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    14 Jan 2011
    Link to this post
    Hi 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
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. higgsy
    higgsy avatar
    336 posts
    Registered:
    05 Aug 2010
    14 Jan 2011
    Link to this post
    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

  4. higgsy
    higgsy avatar
    336 posts
    Registered:
    05 Aug 2010
    14 Jan 2011
    Link to this post
    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
  5. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    14 Jan 2011
    Link to this post
    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
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  6. higgsy
    higgsy avatar
    336 posts
    Registered:
    05 Aug 2010
    14 Jan 2011
    Link to this post
    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();
     
        }
     
     
    }

    I havent physically set up the properties for the ItemHeight, ItemWidth etc which are defined in the template, does that matter just to get the template to show?

    Thanks
    higgsy
  7. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    14 Jan 2011
    Link to this post
    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
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  8. higgsy
    higgsy avatar
    336 posts
    Registered:
    05 Aug 2010
    14 Jan 2011
    Link to this post
    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 */

    I dont see any problems with it, and the js console isnt complaining of errors.

    Any thoughts?
    Thanks
    higgsy
  9. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    14 Jan 2011
    Link to this post
    Hi higgsy,

    Try making the RotatorDesigner public class. If the problem persists I will attach a sample!

    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  10. higgsy
    higgsy avatar
    336 posts
    Registered:
    05 Aug 2010
    14 Jan 2011
    Link to this post
    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">
        

    As you should see from the first line, the SimpleView is hidden by the css class rmpHiddenView. If you look at my previous screenshot you will also notice that both the Simple and Advanced buttons are visible, which I felt was strange seeing as I had specified "Simple" only:

    public class RotatorDesigner : ControlDesignerBase {
     
        protected override void InitializeControls(GenericContainer container) {
     
            base.DesignerMode = ControlDesignerModes.Simple;
     
        }

    Does that heklp suggest what the problem is?

    Thanks
    higgsy
  11. higgsy
    higgsy avatar
    336 posts
    Registered:
    05 Aug 2010
    14 Jan 2011
    Link to this post
    Hi Ivan,

    I found the problem - what a nightmare it was. This was the error:

    NewsRotator.RotatorDesigner.InitializeBase(this, [element]);

    Capital I on initializeBase.

    Very annoying that prototype doesnt raise an error on this.

    Thanks for your help today.

    Regards,
    Al
11 posts, 0 answered