You will need to add the scripts as resources to a separate library and reference them from there to use the script combiner.
Change to provide a walk through
Create a new class library project (for example, "CombinedScipts"), delete the default class.
Add a link to AjaxControlToolkit and System.Web
Add your JS files to the project and change their Build Action property to "Embedded Resource".
Open AssemblyInfo.cs
Add the following:
// You need to add a web resource call for each JS file in the project [assembly: WebResource("CombinedScripts.Console.js", "text/javascript")] [assembly: WebResource("CombinedScripts.Utilities.js", "text/javascript")] // Not setting IncludeScripts or ExcludeScripts marks all scripts as // combinable. [assembly: AjaxControlToolkit.ScriptCombine()]
Add this library as a link to your website project.
In your project, you can add the following between ToolkitScriptManager tags:
<Scripts> <asp:ScriptReference name="CombinedScripts.Console.js" assembly="CombinedScripts" /> <asp:ScriptReference name="CombinedScripts.Utilities.js" assembly="CombinedScripts" /> </Scripts>
Remember that the CombineScripts ToolkitScriptManager property is set to true.
This results in a single call: /pageName.aspx?_TSM_HiddenField_=ToolkitScriptManager1_HiddenField& [...]
You will have merged scripts with comment delimiters like:
//START CombinedScripts.Console.js [...] //END CombinedScripts.Console.js //START CombinedScripts.Utilities.js [...] //END CombinedScripts.Utilities.js
Zhaph - Ben Duguid
source share