You can download the AJAX Control Toolkit from CodePlex. Current version is 40412. Download the AjaxControlToolkit.Binary.NET4.zip file.
In the .zip file, you’ll find the AjaxControlToolkit.dll file. Copy the file to a shared location where you can reference the file from your projects. For instance, C:\Components\AjaxControlToolkit\.
If other developers will be working on the same project, you may want to make another copy of the file and put it in the project’s folder. For instance, you can create a folder named !ref or REF inside the project’s folder and put the .dll there.
There’s no need to deploy this folder to the web server when you’re ready to release you website since the compiler will place another copy of the file in the BIN folder.
Open Visual Studio or Visual Web Developer Express. Create a new Web Application or open the project where you want to use the Ajax Control Toolkit.
Add a reference to AjaxControlToolkit.dll from the location you chose.
If we want to use the controls in a page, we would add this line to the top of the page, right below the <%@ Page %> directive.
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
If you want to automatically make the controls available to all the pages in the project, we would add this to the web.config. We won’t need to register the controls on each page anymore.
<pages> <controls> <add assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagPrefix="asp" /> </controls> </pages>
We can also add the controls to the Toolbox.
- Right-click on the Toolbox.
- Select Add Tab.
- Type Ajax Control Toolkit to name the new tab.
- Right-click inside the new tab.
- Select Choose Items.
- Click on Browse.
- Find the AjaxControlToolkit.dll file. It is a good idea to use the shared location we discussed before.
- All the controls will be selected. Click OK.
All of the controls will now be available so you can easily add them to your pages.
Since the AJAX Control Toolkit is built on top of ASP.NET AJAX, we need to add a ScriptManager or a ScriptManagerProxy control to the page where we’ll use the controls. We talked about this in the last post.
<asp:ScriptManager ID="ScriptManager1" runat="server" />
ACT also offers its own control ToolkitScriptManager that we can use instead of ScriptManager.
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server" />
If none of these controls is found in your page, you would get the exception MissingManifestResourceException with an error like this:
Could not find any resources appropriate for the specified culture or the neutral culture. Make sure “AjaxControlToolkit.Properties.Resources.NET4.resources” was correctly embedded or linked into assembly “AjaxControlToolkit” at compile time, or that all the satellite assemblies required are loadable and fully signed.
Now you’re ready to use the controls in your page. You can view all the controls in action in the official samples page.