Get Started With ASP.NET AJAX Control Toolkit

The AJAX Control Toolkit (ACT) is an open source project built on top of ASP.NET AJAX. It contains a set of AJAX-enabled controls that we can use to easily make our page more interactive.

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.

Ajax Control Toolkit Reference

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.

  1. Right-click on the Toolbox.
  2. Select Add Tab.
  3. Type Ajax Control Toolkit to name the new tab.
  4. Right-click inside the new tab.
  5. Select Choose Items.
  6. Click on Browse.
  7. Find the AjaxControlToolkit.dll file. It is a good idea to use the shared location we discussed before.
  8. All the controls will be selected. Click OK.

Ajax Control Toolkit - Toolbox Items

All of the controls will now be available so you can easily add them to your pages.

Ajax Control Toolkit - Toolbox

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.

Get Free Updates
Related Posts
Comments