Ajax contorl toolkit ToolkitScriptManager Demonstration
You must add a ToolkitScriptManager control to any page that contains Ajax Control Toolkit controls. The ToolkitScriptManager performs two main functions.
To take full advantage of the ToolkitScriptManager, and get the best performance out of a website that uses the Ajax Control Toolkit, you need to understand two features of the ToolkitScriptManager: the CombineScripts HTTP Handler and control bundles.
Using the CombineScripts Handler
To take full advantage of caching, you should register the Ajax Control Toolkit CombineScripts HTTP Handler in your web.config file in both the <httpHandlers> and <system.webServer> sections of your root web.config file like this:
<!-- Using CombineCriptsHandler.axd as path of handler -->
<add verb="*" path="CombineScriptsHandler.axd"
<validation validateIntegratedModeConfiguration="false" />
<!-- Using CombineCriptsHandler as name of handler -->
<add name="CombineScriptsHandler" verb="*"
To make it easier to debug your scripts, Combining, minification, compression, and caching are enabled only in Release mode. You can enable Release mode in your web.config file by setting debug=”false” like this:
<compilation debug="false" />
Alternatively, you can enable Release mode with the ToolkitScriptManager like this:
Using Control Bundles
By default, the ToolkitScriptManager combines all of the scripts required by the entire Ajax Control Toolkit and -- after minifying and compressing the combined scripts -- serves the combined script to the browser. If you are using a subset of Ajax Control Toolkit controls in your web application then you might want to deliver only the scripts that you really need.
Or, your web application might be organized into different sections. You might want to use different subsets of the Ajax Control Toolkit controls on different pages.
You can control how the ToolkitScriptManager combines scripts by defining one or more control bundles. You define control bundles in a configuration file named AjaxControlTookit.config that you place in the root of your application. For example, the following AjaxControlToolkit.config file defines three control bundles:
<!-- works for most pages -->
<!-- Works for pages that use only AccordionExtender -->
<!-- Works for pages that use only CalendarExtender and
You don’t need to do anything special to use the default bundle. If you declare a ToolkitScriptManager without specifying a control bundle then the default bundle is used automatically:
The second control bundle contains a single control. This bundle only contains the scripts and Cascading Style Sheet files required to use the Accordion extender. This second bundle has the name Group1. Here’s how you would use the Group1 control bundle with the ToolkitScriptManager:
Finally, the third control bundle includes both the Calendar extender and the HtmlEditor extender controls. This final bundle has the name Group2. Here’s how you would use the Group2 control bundle with the ToolkitScriptManager:
You can use control bundles with custom controls. When including a custom control in a bundle, you must also provide the name of the custom control’s assembly. For example, the following control bundle includes a custom control named AcmeHtmlEditor:
<!-- Use custom control in bundle -->
Including and Excluding Scripts
You can use <add> and <remove> elements in the AjaxControlToolkit.config file to exclude or
to include Twitter Bootstrap in your control bundle. In that case, you can add the following <add> element
to your AjaxControlToolkit.config file:
In the code above, you should replace MyApp with the name of your Web Forms application.
To get this to work, you need to embed the bootstrap.js file in your Web Forms application's assembly. Open the Properties
Build Action to the value Embedded Resource. Finally, add the following attribute to your Global.asax file:
and far future cached).
The ability to remove scripts from a control bundle is useful when you want to use your own version of jQuery
with the Ajax Control Toolkit. To learn more about using jQuery with the Ajax Control Toolkit, read
Using jQuery with the Ajax Control Toolkit
How It Works
The ToolkitScriptManager uses four attributes to determine which scripts and Cascading Style Sheet files to load and combine. These attributes are server-side attributes applied to Ajax Control Toolkit controls:
ClientCssResource – This attribute represents a Cascading Style Sheet file that has been embedded in an assembly.
RequiredScript – This attribute loads all of the scripts required by a class or a control.
For example, the Calendar extender control includes the following attributes:
Notice that the RequiredScript attribute accepts a number. This number represents the order in which the scripts are loaded.
If you want to create a custom control that works with the ToolkitScriptManager then you need to add these four attributes to your control.
Ajax control toolkit ToolkitScriptManager example with demo in asp .net