views:

608

answers:

1

ASP.NET 3.5 SP1 adds a great new ScriptCombining feature to the ScriptManager object as demonstrated on this video. However he only demonstrates how to use the feature with the ScriptManager on the same page. I'd like to use this feature on a site where the scriptmanager is on the master page but can't figure out how to add the scripts I need for each page programmatically to the manager. I've found this post to use as a starting point, but I'm not really getting very far. can anyone give me a helping hand?

Thanks, Dan

+2  A: 

Give this a shot:

    ScriptReference SRef = new ScriptReference();
    SRef.Path = "~/Scripts/Script.js";


    ScriptManager.GetCurrent(Page).CompositeScript.Scripts.Add(SRef);

That will get the current scriptmanager (even if it is on a master page) and add a script reference to the CompositeScript properties.

TonyB
Thanks. I'll give this a shot when I get in tomorrow
Hmobius