1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Contents of "SimpleScriptView" widget not appearing in designer

Contents of "SimpleScriptView" widget not appearing in designer

4 posts, 0 answered
  1. Chris
    Chris avatar
    9 posts
    Registered:
    08 Aug 2011
    24 Aug 2011
    Link to this post
    Hello,

    We are developing a Sitefinity widget that requires external scripts, so we inherit from SimpleScriptView so that we can register that script reference.

    This works fine on the actual site, but in the designer, the control's contents are not displayed. There is a PUT request made to the ZoneEditorService that should retrieve the control's HTML, but the "Html" field in the JSON response is always coming back null. Publishing the page and going into the designer again displays the widget, but it does not update to reflect changes made in the widget's designer.

    This seems to be true of all widgets that inherit from SimpleScriptView. Is there a preferred way of including an external JavaScript file, or some way of making a widget that derives from SimpleScriptView work as expected?

    Thanks,
    Chris
  2. Stanislav Velikov
    Stanislav Velikov avatar
    1113 posts
    Registered:
    17 Aug 2017
    29 Aug 2011
    Link to this post
    Hello Chris,

    You can reference the external javascript with
    private const string scriptPath = "ScriptViewControl.Resources.MyControl.js";

    private const string controlScript = "Telerik.BlogsContentSelectorsDesignerView.js";
    Under the registration to the layout template path to .ascx file you use in the control. Note javascript resources have to be set as embedded resources and added in assemblyinfo.cs
    [assembly: WebResource("ScriptViewControl.Resources.MyControl.js", "application/x-javascript")]

    If you need to add externaljavascript to the .ascx control you can use
    <sf:JavaScriptEmbedControlrunat="server"ID="jQueryLink"ScriptEmbedPosition="Head"
    </sf:JavaScriptEmbedControl>
    <sf:JavaScriptEmbedControlrunat="server"ID="jQueryUILink"ScriptEmbedPosition="Head"
    </sf:JavaScriptEmbedControl>
    <sf:JavaScriptEmbedControlrunat="server"ID="JavaScriptEmbedControl6"Url="~/RTC_Scripts/series.js"
        ScriptEmbedPosition="Head">
    </sf:JavaScriptEmbedControl>
    <sf:JavaScriptEmbedControlrunat="server"ID="JavaScriptEmbedControl5"Url="~/RTC_Scripts/jquery.anythingslider.js"
        ScriptEmbedPosition="Head">
    </sf:JavaScriptEmbedControl>


    Greetings,
    Stanislav Velikov
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

  3. Chris
    Chris avatar
    9 posts
    Registered:
    08 Aug 2011
    29 Aug 2011
    Link to this post
    Hi,

    Thank you for the reply -- unfortunately, that does not resolve the problem. I am including the JavaScript as an embedded resource (included in the AssemblyInfo) and it is working at run-time. The problem is that the control does not refresh in the back-end until I click "Publish", unlike other controls, which refresh immediately.

    Thank you,
    Chris
  4. Stanislav Velikov
    Stanislav Velikov avatar
    1113 posts
    Registered:
    17 Aug 2017
    01 Sep 2011
    Link to this post
    Hi Chris,

    Thank you for the clarifications. To refresh the designer immediately refer to this tutorial and sample code of the designer javascript files. In the video you can see the control refreshes the updated content immediately.

    // bind designer properties back to widget
            controlData.Name = jQuery("#txtName").val();


    Kind regards,
    Stanislav Velikov
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

4 posts, 0 answered