This is a migrated thread and some comments may be shown as answers.

Not combining scripts

8 Answers 228 Views
ScriptManager and StyleSheetManager
This is a migrated thread and some comments may be shown as answers.
Matt
Top achievements
Rank 1
Matt asked on 25 Jan 2011, 11:33 PM
I have to add a radscriptmanager in a base class and I want to combine the script however it doesn't appear to work. I am ensuring that this control is added as the first control of the form. I have the following...

RadScriptManager sm = new RadScriptManager();
                sm.ScriptMode = ScriptMode.Release;
                ScriptReference telerikCore = new ScriptReference("~/Scripts/Common/Core.js");
                ScriptReference jquery = new ScriptReference("~/Scripts/Common/jQuery.js");
                ScriptReference jQueryPlugins = new ScriptReference("~/Scripts/Common/jQueryPlugins.js");
                ScriptReference navigationScripts = new ScriptReference("~/Scripts/Common/Navigation/NavigationScripts.js");
                ScriptReference radMenuScripts = new ScriptReference("~/Scripts/Menu/RadMenuScripts.js");
                ScriptReference radCalendarCommonScript = new ScriptReference("~/Scripts/Calendar/RadCalendarCommonScript.js");
                ScriptReference radCalendarScript = new ScriptReference("~/Scripts/Calendar/RadCalendarScript.js");
                ScriptReference jqueryValidate = new ScriptReference("~/js/jquery.validate.js");
                ScriptReference slimStatAnalytics = new ScriptReference("~/slimstat/?js");
                sm.Scripts.Add(telerikCore);
                sm.Scripts.Add(jquery);
                sm.Scripts.Add(jQueryPlugins);
                sm.Scripts.Add(navigationScripts);
                sm.Scripts.Add(radMenuScripts);
                sm.Scripts.Add(radCalendarCommonScript);
                sm.Scripts.Add(radCalendarScript);
                sm.Scripts.Add(jqueryValidate);
                sm.Scripts.Add(slimStatAnalytics);

                sm.EnableScriptCombine = true;
                sm.EnablePageMethods = true;
                sm.OutputCompression = OutputCompression.AutoDetect;

                form.Controls.AddAt(0, sm);

I get a Telerik.Web.UI.WebResource.axd file containing 10,000 lines of code which looks like Ms Ajax related js - no reference to Telerik in there at all. My page still contains the scripts as separate links. Do I need to set enableembeddedscripts to false on all my rad controls? How about the RegisterWithScriptManager property on radmenu?

If I create another page and do this in mark up it works fine. What am I doing wrong? I don't suppose you have an example of this working?

Thanks
Matt

8 Answers, 1 is accepted

Sort by
0
Fit2Page
Top achievements
Rank 2
Iron
Iron
Iron
answered on 08 Feb 2012, 10:13 AM
I also have an issue with the RadScriptManager not combining scripts. i have the following configuration
<telerik:RadScriptManager ID="ScriptManager1" EnableScriptCombine="true" OutputCompression="Forced" runat="server">
<Groups>
<telerik:ScriptReferenceGroup>
<Scripts>
<asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" /> 
<asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" /> 
<asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
<asp:ScriptReference Path="~/js/jquery.safermailto.js" />
<asp:ScriptReference Path="~/js/jquery.posFooterF2P_v1.js" />
<asp:ScriptReference Path="~/js/jquery.flow.1.2.auto.js" />
<asp:ScriptReference Path="~/js/InitF2P.js" />
</Scripts>
</telerik:ScriptReferenceGroup>
</Groups>
</telerik:RadScriptManager>

The last 4 .js files are send seperately to the client.

BR,
Marc
0
Simon
Telerik team
answered on 08 Feb 2012, 12:11 PM
Hi guys,

The answer to both of your questions is: RadScriptManager (and ScriptManager for that matter) does not combine external (non-embedded) scripts. There is away to combine such in .net 3.5 and 4.0 which is built-in in ScriptManager - put the external scripts in a CompositeScript. They will be combined into one request.

I hope this helps.

Kind regards,
Simon
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Fit2Page
Top achievements
Rank 2
Iron
Iron
Iron
answered on 08 Feb 2012, 12:40 PM
Of course I want to use the telerik RadScriptManager :-)
This option shouldn't be too hard for telerik, It is already done in the Stylesheet Manager...

Marc
0
Simon
Telerik team
answered on 08 Feb 2012, 01:29 PM
Hi Fit2Page,

RadScriptManager inherits ScriptManager, so it also supports CompositeScript. Please excuse me for not being clear enough.

RadStyleSheetManager supports combining external style sheets, which is something we have implemented easily because the control is built from the ground up. Still we are looking forward to introducing the same functionality in RSM, however this is in our plans for the next Qs.

All the best,
Simon
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Fit2Page
Top achievements
Rank 2
Iron
Iron
Iron
answered on 08 Feb 2012, 02:00 PM
Thank you Simon it works.

When I add to the RSM
<asp:ScriptReference Path="http://s7.addthis.com/js/250/addthis_widget.js#username=fit2page" />
Strange enough i get the message:

The relative virtual path 'http:/ss7.addthis.com/js/250/addthis_widget.js#username=fit2page' is not allowed here.


Mind the single slash after http:

Any suggestions for this one?

Marc
0
Simon
Telerik team
answered on 13 Feb 2012, 12:18 PM
Hi Fit2Page,

I tested this code:
<telerik:RadScriptManager ID="RadScriptManager1" runat="server">
    <Scripts>
        <asp:ScriptReference Path="http://s7.addthis.com/js/250/addthis_widget.js#username=fit2page" />
    </Scripts>
</telerik:RadScriptManager>

with the latest version of Telerik.Web.UI and it worked fine - all script and css files loaded properly. Which version are you using?

Greetings,
Simon
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Fit2Page
Top achievements
Rank 2
Iron
Iron
Iron
answered on 13 Feb 2012, 03:55 PM
Hi Simon,

It happens when I use <CompositeScript>:
<telerik:RadScriptManager ID="ScriptManager1" OutputCompression="Forced" runat="server">
<CompositeScript>
<Scripts>
<asp:ScriptReference Path="http://s7.addthis.com/js/250/addthis_widget.js#username=fit2page" />
</Scripts>
</CompositeScript>
</telerik:RadScriptManager>
0
Simon
Telerik team
answered on 14 Feb 2012, 02:44 PM
Hi Fit2Page,

Thank you for reminding me - I forgot about the detail.

This same exception is thrown by ScriptManager (if you replace RadScriptManager with it, you will see it) and RSM inherits from it.

The exception is thrown because SM requires scripts in a CompositeScript to be local, i.e. in the same application, because it reads them from the file system in order to combine them.

I think there is nothing else we could do about this. The best approach is to use only local scripts.

Kind regards,
Simon
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
ScriptManager and StyleSheetManager
Asked by
Matt
Top achievements
Rank 1
Answers by
Fit2Page
Top achievements
Rank 2
Iron
Iron
Iron
Simon
Telerik team
Share this question
or