Telerik RadScriptManager - error when merging js files

I am trying to merge multiple links to a js file using Telerik script manager. Here is the code I have on page load:

        System.Web.UI.ScriptReference jsFile1 = new System.Web.UI.ScriptReference('/virtual_folder/jsfile1.js');
        System.Web.UI.ScriptReference jsFile2 = new System.Web.UI.ScriptReference('/virtual_folder/jsfile2.js');


        this.Master.ScriptManager.CompositeScript.Scripts.Add(jsFile1);
        this.Master.ScriptManager.CompositeScript.Scripts.Add(jsFile2);

      

I am getting the error:

[NullReferenceException: Object reference not set to object instance.] System.Collections.ObjectModel.Collection`1.Add (T element) +18

Telerik.Web.UI.RadScriptManager.Page_PreRenderComplete (object sender, EventArgs e) +95

System.EventHandler.Invoke (Object Sender, EventArgs e) +0

System.Web.UI.Page.OnPreRenderComplete (EventArgs e) +8695102

System.Web.UI.Page.ProcessRequestMain (Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1029

What am I doing wrong?

0


a source to share


1 answer


I think the merging script only works for inline resources, so you will need to inline your js files inside the dll.

On the other hand, you know you can use

 this.Master.ScriptManager.

      



tried using

 RadScriptManager.GetCurrent(this)

      

I am assuming that you are calling this from the aspx page and not with the ascx control, otherwise you must use this.Page.

+1


a source







All Articles