tags:

views:

1161

answers:

1

I'm trying to combine multiple js file references using Telerik's 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'm getting an error:

[NullReferenceException: Object reference not set to an instance of an object.] System.Collections.ObjectModel.Collection`1.Add(T item) +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?

+1  A: 

I think that the script combining only works for embedded resources currently so you would have to embed your js Files inside a dll.

On a side note you know you can use

 this.Master.ScriptManager.

tried using

 RadScriptManager.GetCurrent(this)

I am assuming you are calling this from an aspx page and not an ascx control, otherwise you have to use this.Page.

Sean Molam