Using the AJAX Control Toolkit with SharePoint 2010

The AJAX Control Toolkit offers so much useful functionality, however for some reason Microsoft refuses to integrate it as part of their product. This has caused problems with SharePoint 2003 – 2010, however as SharePoint now has standard Ajax integration we are now faced with another problem.

With previous versions of SharePoint you would need to add the AJAX references to the Web.config file as well as register the AJAX assemblies. In addition you would need to do the same for the AJAX Control Toolkit as well as incorporating a script manager into your master pages.Well with SharePoint 2010, the AJAX stuff is already there, but the script managers do not work with the AJAX Control Toolkit. Here is how I finally managed to get this working:

Registering the AJAX Control Toolkit

First you need to download the AJAX Control Toolkit binaries. After some headaches I found out that the latest release does not work with SharePoint 2010. You get a bunch of ‘sys’ errors after implementation. You will therefore need to download the 30930 version which can be found here.

Copy the “AjaxControlToolkit.dll” file into the “<Drive>\inetpub\wwwroot\wss\VirtualDirectories\80\bin” SharePoint directory (obviously if you didn’t use port 80, the path would have a different port number).

Open up your Web.config file and find the <assemblies> section add the following entry (notice that the version includes *.28736, this took me a while to figure out):

<add assembly=”AjaxControlToolkit, Version=3.0.30930.28736, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e” />

Also add the following entry in the Web.config file in the <SafeControls> section:

<SafeControl Assembly=”ajaxcontroltoolkit, Version=3.0.30930.28736, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e, processorArchitecture=MSIL” Namespace=”AjaxControlToolkit” TypeName=”*” />

Adding the AJAX Control Toolkit to Visual Studio 2010

Open up VSTO and start a new Web Part project. When you have the project open, add a new reference to the project by browsing to the “AjaxControlToolkit.dll” file in the “<Drive>\inetpub\wwwroot\wss\VirtualDirectories\80\bin”  directory.

Once you have this added to your project, go ahead and add the following line to your user control:

<%@ Register Assembly=”AjaxControlToolkit” Namespace=”AjaxControlToolkit” TagPrefix=”asp” %>

Now, add a new Tab to your Toolbox, then right click and ‘choose items’. Browse to the “AjaxControlToolkit.dll” file in the “<Drive>\inetpub\wwwroot\wss\VirtualDirectories\80\bin”  directory and add the controls. You should see the following results:

WAIT! There’s more

OK, you have everything in place and you start to build a Web Part with the AJAX Toolkit Controls and find that the control is being rendered, but it is not functioning. You get a Javascript error pointing to your AJAX files being out of date. This is because SharePoint 2010 now has a ScriptManager added to every Master Page by default. You need to open up the Master Page you’re using (typically with SharePoint Designer) and remove the existing <asp:ScriptManager> tag and replace it with the following:

<asp:ToolkitScriptManager ID=”ToolkitScriptManager1″ runat=”server” />

as well as adding the following assembly reference:

<%@ Register Assembly=”AjaxControlToolkit” Namespace=”AjaxControlToolkit” TagPrefix=”asp” %>

Woohoo. You now have the Toolkit fully functional in SharePoint 2010. Hope this helps you save some of the headaches I went through.

About

Strategic Knowledge Management Leader focused on Knowledge Management, Client Relationship Management, Business Process Management, Business Intelligence, Web Development, Application Architecture and Database Architecture.

Tagged with: , , , , ,
Posted in .NET, MS SharePoint, Web Development
15 comments on “Using the AJAX Control Toolkit with SharePoint 2010
  1. damske kabelky says:

    Hi am grateful for the script. Good work, this indeed did help me.

  2. Reeshof Tandarts says:

    Hey thanks for yet another nice and interesting post. Where do you find your inspiration for all this?

  3. gminny says:

    I didn’t quite understand this when I first read it. But when I went through it a second time, it all became clear. Thanks for the insight. Absolutely something to think about.

  4. Sam Brown says:

    I have followed this example and trawled the internet but I can not get this working. I am getting the following error:
    The control type ‘AjaxControlToolkit.ToolkitScriptManager’ is not allowed on this page. The type is not registered as safe.
    I have updated the Web.config as follows:

    so this should work – Any help would be appreciated

  5. I’m assuming you are adding the scriptmanager to the master page. Your web.config setting was not included in your comment, please add the safe control setting text you are using and the assembly register code from your master page. I’ll be happy to take a look.

  6. nabeel says:

    Thanks a lot. Fantastic post

    keep posting

  7. S Wargearlak says:

    this post is very usefull thx!

  8. anon says:

    Thanks, this worked for me. Note that in SharePoint 2010 the default master page is not default.master (as you would expect) but v4.master! I lost a few hours on this. Damn you Microsoft.

  9. Nauman says:

    Thanks a zillions!!! I was struggling for 2 days before I got this post…. Keep posting :)

  10. hey i am getting Parser Error Message: Could not load file or assembly ‘AjaxControlToolkit, Version=3.0.30930.28736 Culture=neutral, PublicKeyToken=28f01b0e84b6d53e’ or one of its dependencies. The given assembly name or codebase was invalid. (Exception from HRESULT: 0×80131047)
    exception after doing this step where i got wrong

    • This error means you are to using the correct version of the AjaxControlKit. Make sure the version number matches exactly, as SharePoint 2010 has some comparability issues with later versions.

  11. JK says:

    great post,Thanks.
    JK

  12. Anitha says:

    This article is very helpful and useful for people who try to integrate ajax into sharepoint 2010.. Thanks for posting

1 Pings/Trackbacks for "Using the AJAX Control Toolkit with SharePoint 2010"

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>