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

Forums / Developing with Sitefinity / ScriptManager combining embedded resources causing issues

ScriptManager combining embedded resources causing issues

8 posts, 1 answered
  1. Jacques
    Jacques avatar
    427 posts
    Registered:
    28 Jun 2007
    13 Jul
    Link to this post

    So I'm working on reducing the number of requests on an older SF7.1 site and coming up with some issues. 

    Here's the script manager code: 

    01.<asp:ScriptManager ID="ScriptManager1" runat="server" LoadScriptsBeforeUI="false">
    02.    <CompositeScript>
    03.        <Scripts>
    04.            <asp:ScriptReference Name="Telerik.Sitefinity.Resources.Scripts.jquery-1.8.3.min.js" Assembly="Telerik.Sitefinity.Resources" />
    05.            <asp:ScriptReference Name="JawitzCoZa.Web.js.jquery-ui.min.js" Assembly="JawitzCoZa.Web, Version=6.0.4100.0, Culture=neutral, PublicKeyToken=null" />
    06.            <asp:ScriptReference Name="Telerik.Web.UI.Common.Core.js" Assembly="Telerik.Web.UI, Version=2014.3.1209.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4" />
    07.            <asp:ScriptReference Name="Telerik.Web.UI.Common.jQuery.js" Assembly="Telerik.Web.UI, Version=2014.3.1209.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4" />
    08.            <asp:ScriptReference Name="Telerik.Web.UI.Common.jQueryPlugins.js" Assembly="Telerik.Web.UI, Version=2014.3.1209.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4" />
    09.            <asp:ScriptReference Name="Telerik.Web.UI.Common.Scrolling.ScrollingScripts.js" Assembly="Telerik.Web.UI, Version=2014.3.1209.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4" />
    10.            <asp:ScriptReference Name="Telerik.Web.UI.Common.Navigation.OData.OData.js" Assembly="Telerik.Web.UI, Version=2014.3.1209.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4" />
    11.            <asp:ScriptReference Name="Telerik.Web.UI.Common.AnimationFramework.AnimationFramework.js" Assembly="Telerik.Web.UI, Version=2014.3.1209.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4" />
    12.            <asp:ScriptReference Name="Telerik.Web.UI.Common.Navigation.NavigationScripts.js" Assembly="Telerik.Web.UI, Version=2014.3.1209.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4" />
    13.            <asp:ScriptReference Name="Telerik.Web.UI.Common.Navigation.OverlayScript.js" Assembly="Telerik.Web.UI, Version=2014.3.1209.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4" />
    14.            <asp:ScriptReference Name="Telerik.Web.UI.Menu.RadMenuScripts.js" Assembly="Telerik.Web.UI, Version=2014.3.1209.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4" />
    15.            <asp:ScriptReference Name="Telerik.Web.UI.Menu.MenuItem.RadMenuItem.js" Assembly="Telerik.Web.UI, Version=2014.3.1209.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4" />
    16.            <asp:ScriptReference Name="Telerik.Web.UI.Menu.Views.ClassicView.js" Assembly="Telerik.Web.UI, Version=2014.3.1209.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4" />
    17.            <asp:ScriptReference Name="Telerik.Sitefinity.Web.UI.ContentUI.Views.Scripts.ViewBase.js" Assembly="Telerik.Sitefinity, Version=7.3.5610.0, Culture=neutral, PublicKeyToken=b28c218413bdf563" />
    18.            <asp:ScriptReference Name="Telerik.Web.UI.ListView.RadListViewScripts.js" Assembly="Telerik.Web.UI, Version=2014.3.1209.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4" />
    19.            <asp:ScriptReference Name="Telerik.Sitefinity.Web.Scripts.UserPreferences.js" Assembly="Telerik.Sitefinity, Version=7.3.5610.0, Culture=neutral, PublicKeyToken=b28c218413bdf563" />
    20.            <asp:ScriptReference Name="Telerik.Sitefinity.Web.UI.Fields.Scripts.IField.js" Assembly="Telerik.Sitefinity, Version=7.3.5610.0, Culture=neutral, PublicKeyToken=b28c218413bdf563" />
    21.            <asp:ScriptReference Name="Telerik.Sitefinity.Web.UI.Validation.Scripts.Validator.js" Assembly="Telerik.Sitefinity, Version=7.3.5610.0, Culture=neutral, PublicKeyToken=b28c218413bdf563" />
    22.            <asp:ScriptReference Name="Telerik.Sitefinity.Web.UI.Fields.Scripts.FieldControl.js" Assembly="Telerik.Sitefinity, Version=7.3.5610.0, Culture=neutral, PublicKeyToken=b28c218413bdf563" />
    23.            <asp:ScriptReference Name="Telerik.Sitefinity.Web.UI.Fields.Scripts.FieldDisplayMode.js" Assembly="Telerik.Sitefinity, Version=7.3.5610.0, Culture=neutral, PublicKeyToken=b28c218413bdf563" />
    24.            <asp:ScriptReference Name="Telerik.Sitefinity.Resources.Scripts.xregexp-min.js" Assembly="Telerik.Sitefinity.Resources" />
    25.            <asp:ScriptReference Name="Telerik.Sitefinity.Resources.Scripts.xregexp-unicode-base.js" Assembly="Telerik.Sitefinity.Resources" />
    26.            <asp:ScriptReference Name="Telerik.Sitefinity.Web.UI.Fields.Scripts.TextField.js" Assembly="Telerik.Sitefinity, Version=7.3.5610.0, Culture=neutral, PublicKeyToken=b28c218413bdf563" />
    27.        </Scripts>
    28.    </CompositeScript>
    29.    <Scripts>
    30.        <asp:ScriptReference Name="MicrosoftAjax.js" Assembly="" />
    31.        <asp:ScriptReference Name="MicrosoftAjaxWebForms.js" Assembly="" />
    32.    </Scripts>
    33.</asp:ScriptManager>

    Problem 1: 

    When I add the references on lines 30 and 31 above to the composite script it fails with the following: 

    The resource URL cannot be longer than 2048 characters. If using a CompositeScriptReference, reduce the number of ScriptReferences it contains, or combine them into a single static file and set the Path property to the location of it.

    Problem 2: 

    When I moved those two files out of CompositeScripts into Scripts the site worked again but now I'm getting JavaScript errors in the Admin section when I try to edit the Template that I'm making the changes in. See attached screenshot for a list of errors. 

    I think this might be related to the ordering of the script files? I'm not sure how ScriptManager handles this but I got the list be executing the following code in the Master Page's code behind (which I found on Stack): 

    public partial class App_Master_Home : MasterPageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            ScriptManager.GetCurrent(this.Page)
              .ResolveScriptReference += new EventHandler<ScriptReferenceEventArgs>(ResolveScriptReferenceHandler);
        }
     
        List<string> ScriptRefs = new List<string>();
        private void ResolveScriptReferenceHandler(object sender, ScriptReferenceEventArgs e)
        {
            ScriptRefs.Add("<asp:ScriptReference Name=\"" + e.Script.Name + "\" Assembly=\"" + e.Script.Assembly + "\" />");
        }
     
        protected override void Render(HtmlTextWriter output)
        {
            var list = ScriptRefs.Distinct();
            foreach (var item in list)
            {
                output.Write(output.NewLine);
                output.WriteLine(item.ToString());
            }
             
            base.Render(output);       
        }
    }

    Problem 3: 

    I'm getting a great reduction in the number requests (down from 31 to 9), but why does the ScriptManager still output 4 AXD files instead of 1? 

  2. Victor Leontyev
    Victor Leontyev avatar
    65 posts
    Registered:
    01 Jul 2014
    14 Jul
    Link to this post

    Hi Jacques. If you want to solve problem 1, you need to split your resources to different ScriptManagerProxy

    Old thread with the same problem http://www.telerik.com/forums/radscriptmanager-which-proxy-should-i-use-quot-the-resource-url-cannot-be-longer-than-1024-characters-quot

    If you need example how to use ScriptManagerProxy, let me know.

  3. Jacques
    Jacques avatar
    427 posts
    Registered:
    28 Jun 2007
    14 Jul in reply to Victor Leontyev
    Link to this post

    Thanks Victor. 

    I'd like to see an example yes, please. Since this is Sitefinity I'm not sure where I would put the proxies or if I just create a dummy user control to do this, but even then, Problem 2 is of a bigger concern since the combining of scripts is causing issues in the back-end. 

  4. Jacques
    Jacques avatar
    427 posts
    Registered:
    28 Jun 2007
    18 Jul in reply to Victor Leontyev
    Link to this post
    Victor? 
  5. Victor Leontyev
    Victor Leontyev avatar
    65 posts
    Registered:
    01 Jul 2014
    18 Jul in reply to Jacques
    Link to this post

    Hi Jacques. Here the example of master file

    <telerik:RadScriptManager ID="RadScriptManager1" CompositeScript-ScriptMode="Release" EnableScriptGlobalization="True" EnableScriptLocalization="False" runat="server" CompositeScript-NotifyScriptLoaded="True" LoadScriptsBeforeUI="True" AjaxFrameworkMode="Disabled">
                <CompositeScript>
                    <Scripts>
                        <asp:ScriptReference Name="Telerik.Sitefinity.Resources.Scripts.MicrosoftAjax.js" Assembly="Telerik.Sitefinity.Resources" />
                        <asp:ScriptReference Name="Telerik.Sitefinity.Resources.Scripts.MicrosoftAjaxWebForms.js" Assembly="Telerik.Sitefinity.Resources" />
                        <asp:ScriptReference Name="WebForms.js" Assembly="System.Web" />
                        <asp:ScriptReference Name="Telerik.Web.UI.Common.Core.js" Assembly="Telerik.Web.UI" />
                        <asp:ScriptReference Name="Telerik.Web.UI.ListView.RadListViewScripts.js" Assembly="Telerik.Web.UI" />
                        <asp:ScriptReference Name="Telerik.Web.UI.Common.jQuery.js" Assembly="Telerik.Web.UI" />
                    </Scripts>
                </CompositeScript>
            </telerik:RadScriptManager>
            <asp:ScriptManagerProxy ID="ScriptManagerProxy1" runat="server">
                <CompositeScript>
                    <Scripts>
                        <asp:ScriptReference Name="Telerik.Sitefinity.Resources.Scripts.xregexp-min.js" Assembly="Telerik.Sitefinity.Resources" />
                        <asp:ScriptReference Name="Telerik.Sitefinity.Resources.Scripts.xregexp-unicode-base.js" Assembly="Telerik.Sitefinity.Resources" />
                    </Scripts>
                </CompositeScript>
            </asp:ScriptManagerProxy>
            <asp:ScriptManagerProxy ID="ScriptManagerProxy2" runat="server">
                <CompositeScript>
                    <Scripts>
                        <asp:ScriptReference Name="Telerik.Sitefinity.Web.SitefinityJS.Telerik.Sitefinity.js" Assembly="Telerik.Sitefinity" />
                        <asp:ScriptReference Name="Telerik.Sitefinity.Web.SitefinityJS.Utility.Querystring.js" Assembly="Telerik.Sitefinity" />
                        <asp:ScriptReference Name="Telerik.Sitefinity.Web.UI.Fields.Scripts.FormManagerEventArgs.js" Assembly="Telerik.Sitefinity" />
                        <asp:ScriptReference Name="Telerik.Sitefinity.Web.UI.Fields.Scripts.FormManager.js" Assembly="Telerik.Sitefinity" />
                        <asp:ScriptReference Name="Telerik.Sitefinity.Web.UI.Fields.Scripts.IField.js" Assembly="Telerik.Sitefinity" />
                        <asp:ScriptReference Name="Telerik.Sitefinity.Web.UI.Validation.Scripts.Validator.js" Assembly="Telerik.Sitefinity" />
                        <asp:ScriptReference Name="Telerik.Sitefinity.Web.UI.Fields.Scripts.FieldControl.js" Assembly="Telerik.Sitefinity" />
                        <asp:ScriptReference Name="Telerik.Sitefinity.Web.UI.Extenders.Scripts.ExpandableExtender.js" Assembly="Telerik.Sitefinity" />
                        <asp:ScriptReference Name="Telerik.Sitefinity.Web.UI.Fields.Scripts.TextField.js" Assembly="Telerik.Sitefinity" />
                        <asp:ScriptReference Name="Telerik.Sitefinity.Web.UI.Fields.Scripts.FieldDisplayMode.js" Assembly="Telerik.Sitefinity" />
                        <asp:ScriptReference Name="Telerik.Sitefinity.Modules.Forms.Web.UI.Scripts.FormTextBox.js" Assembly="Telerik.Sitefinity" />
                        <asp:ScriptReference Name="Telerik.Sitefinity.Web.UI.Fields.Scripts.Choice.js" Assembly="Telerik.Sitefinity" />
                        <asp:ScriptReference Name="Telerik.Sitefinity.Web.UI.Fields.Scripts.RenderChoicesAs.js" Assembly="Telerik.Sitefinity" />
                        <asp:ScriptReference Name="Telerik.Sitefinity.Web.UI.Fields.Scripts.ChoiceField.js" Assembly="Telerik.Sitefinity" />
                        <asp:ScriptReference Name="Telerik.Sitefinity.Modules.Forms.Web.UI.Scripts.FormCheckboxes.js" Assembly="Telerik.Sitefinity" />                   
                        <asp:ScriptReference Name="Telerik.Sitefinity.Modules.Forms.Web.UI.Scripts.FormDropDownList.js" Assembly="Telerik.Sitefinity" />
                        <asp:ScriptReference Name="Telerik.Sitefinity.Modules.Forms.Web.UI.Scripts.FormParagraphTextBox.js" Assembly="Telerik.Sitefinity" />
                        <asp:ScriptReference Name="Telerik.Sitefinity.Web.UI.ContentUI.Views.Scripts.ViewBase.js" Assembly="Telerik.Sitefinity" />
                        <asp:ScriptReference Name="Telerik.Sitefinity.Web.Scripts.UserPreferences.js" Assembly="Telerik.Sitefinity" />
                    </Scripts>
                </CompositeScript>
            </asp:ScriptManagerProxy>

     

  6. Jacques
    Jacques avatar
    427 posts
    Registered:
    28 Jun 2007
    19 Jul in reply to Victor Leontyev
    Link to this post

    Hi Victor, 

    Can you provide a bit of a description of what and why you're doing this? 

    I.e. I see you've used a Telerik RadScriptManager and then added two Proxies presumably on the same Master Page. 

    1. Are you ordering this in a specific way? I.e. It's safe to use as you've added it here or is this generalised? 
    2. Why two additional proxies? 
    3. Does this resolve backend issues? 

    Whilst I wait for clarity from you, I've gone the route of dynamically adding script references to the ScriptManager but only if the page is not in DesignMode, which helped resolve the backend issues. 

  7. Victor Leontyev
    Victor Leontyev avatar
    65 posts
    Registered:
    01 Jul 2014
    19 Jul in reply to Jacques
    Link to this post

    1) I ordered it in ranodm way. It's tested and working for me and my project , but i can't give 100% that it safe in any cases

    2) I splitted all scripts for two proxies, because they have restriction (if you will try to use one, it will raise error: The resource URL cannot be longer than 2048 characters)

    3) All backend features is working fine for me

    Answered
  8. Jacques
    Jacques avatar
    427 posts
    Registered:
    28 Jun 2007
    10 Aug in reply to Victor Leontyev
    Link to this post
    Thanks Victor, I've followed a similar route but did some of it programatically because it was definitely giving me issues in the back end. 
8 posts, 1 answered