views:

673

answers:

2

I'd like to use the ScriptManager and CompositeScript components in my master page to include site-wide javascript, but add to that list in my "Web Content Form". I'm sure that can be done in the code-behind, but optimally I'd like to do it in markup. Can this sort of thing be done?

In: MasterPage.master

<asp:ScriptManager ID="ScriptManager" runat="server" EnableScriptCombine="True">
    <CompositeScript>
        <Scripts>
            <asp:ScriptReference name="" Assembly="" Path="/client/js/main.js"/>      
        </Scripts>
    </CompositeScript>
</asp:ScriptManager>

In: Content.aspx

<asp:ScriptReference name="" Assembly="" Path="/client/js/other.js"/>
+3  A: 

Try using the <asp:ScriptManagerProxy> tag. It's got the same child tags as script manager, but its designed to be used on the content form. (You won't get the 'Only one ScriptManager per page' error)

I'm not sure if that's exactly what you are looking for, because the script you add via the ScriptManagerProxy is only available on the ContentForm that you add it on (I think). It wouldn't be site wide. However, if you need it to be site wide, why not just added it to the MasterPage anyway?

Hope that helps!

Zachary Yates
A: 

It's absolutely what I was looking for, thanks!