asp.net ajax toolkit,combine scripts in asp.net ajax toolkit

You would need to add the scripts as resources to a seperate library and reference them from there to take advantage of the script combiner.

Edit to provide an walk through

Create a new Class Library project (called for example "CombinedScipts"), remove the default class.

Add a reference to both the AjaxControlToolkit and System.Web

Add your JS files to the project, and change their Build Action property to "Embedded Resource".

Open the AssemblyInfo.cs file

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 reference in your web site project.

In your project, you can then add the following between the ToolkitScriptManager tags:

assembly="CombinedScripts" />

assembly="CombinedScripts" />

Not forgetting to ensure that the CombineScripts property of the ToolkitScriptManager is set to true.

This then results in one call to something like:

/pageName.aspx?_TSM_HiddenField_=ToolkitScriptManager1_HiddenField&[...]

Which will have your combined scripts in, with comment delimiters like:

//START CombinedScripts.Console.js

[...]

//END CombinedScripts.Console.js

//START CombinedScripts.Utilities.js

[...]

//END CombinedScripts.Utilities.js

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值