<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Combining Scripts</title> </head> <body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> <CompositeScript> <Scripts> <asp:ScriptReference Path="~/Scripts/Script1.js" /> <asp:ScriptReference Path="~/Scripts/Script2.js" /> <asp:ScriptReference Path="~/Scripts/Script3.js" /> </Scripts> </CompositeScript> </asp:ScriptManager> <h2>Combining Scripts</h2> <p>This example shows how to combine multiple client scripts into a single composite script.</p> <div> <input id="Button1" type="button" value="Button 1" onclick="buttonClick1()" /> <span id="Span1"></span><br /><br /> <input id="Button2" type="button" value="Button 2" onclick="buttonClick2()" /> <span id="Span2"></span><br /><br /> <input id="Button3" type="button" value="Button 3" onclick="buttonClick3()" /> <span id="Span3"></span> </div> </form> </body> </html>
function buttonClick1() { var text = Sys.UI.DomElement.getElementById("Span1"); text.innerHTML = "You clicked Button 1. (Script1)"; } function buttonClick2() { var text = Sys.UI.DomElement.getElementById("Span2"); text.innerHTML = "You clicked Button 2. (Script2)"; }function buttonClick3() { var text = Sys.UI.DomElement.getElementById("Span3"); text.innerHTML = "You clicked Button 3. (Script3)"; }
<asp:ScriptManager id="SM1" runat="server"> <CompositeScript> <Scripts> <asp:ScriptReference Name="MicrosoftAjax.js"/> <asp:ScriptReference Name="Custom.Extender.1.js" Assembly="Custom" /> <asp:ScriptReference Path="Scripts/Custom2.js" /> <asp:ScriptReference Name="Custom.Extender.2.js" Assembly="Custom" /> <asp:ScriptReference Name="Custom.Extender.3.js" Assembly="Custom" /> </Scripts> </CompositeScript> </asp:ScriptManager>
<asp:CompositeScript Path="~/Scripts/MyCompositeScript.js">
<asp:ScriptManager id="SM1" runat="server"> <CompositeScript> <Scripts> <asp:ScriptReference Name="MicrosoftAjax.js"/> <asp:ScriptReference Name="Custom.Extender.1.js" Assembly="Custom" /> <asp:ScriptReference Path="~/Scripts/Custom2.js" /> <asp:ScriptReference Name="Custom.Extender.2.js" Assembly="Custom" /> <asp:ScriptReference Name="Custom.Extender.3.js" Assembly="Custom" /> <asp:ScriptReference Name="Custom.Extender.4.js" Assembly="Custom" /> </Scripts> </CompositeScript> </asp:ScriptManager><asp:UpdatePanel runat="server"...> <ContentTemplate> ... <cc:custom4 runat="server" id="cc4"... /> ... </ContentTemplate> </asp:UpdatePanel>