Contents of "SimpleScriptView" widget not appearin

Posted by Community Admin on 04-Aug-2018 13:41

Contents of "SimpleScriptView" widget not appearing in designer

All Replies

Posted by Community Admin on 24-Aug-2011 00:00

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

Posted by Community Admin on 29-Aug-2011 00:00

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 >>

Posted by Community Admin on 29-Aug-2011 00:00

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

Posted by Community Admin on 01-Sep-2011 00:00

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 >>

This thread is closed