Back to previous

Integrate Ajax Control Toolkit into Sharepoint

I wanted to use Ajax control toolkit in Sharepoint, and had not had any luck until I spent the whole day debugging and getting it to work. I already had Ajax integrated in Sharepoint, so it should be fairly easy to just add in AjaxControlToolkit, but the problem is the latest version of it actually requires you to use ToolkitScriptManager instead of ScriptManager, otherwise your control will not work and you will see a Javascript error of "Please wait while scripts are loaded".

So, to change the ScriptManager to ToolkitScriptManager in the master page, it ain't easy as Sharepoint will throw the error of unknown server tag: ToolkitScriptManager. To workaround that, we need to add some references in web.config of Sharepoint:

In my Controls tag in web.config, I added an addition mapping for asp tag prefix controls:

<add tagPrefix="asp" namespace="AjaxControlToolkit" assembly="AjaxControlToolkit, 
Version=3.0.31106.0, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e" />

What that does is it will add all ajax controls into standard asp tagged controls. For example, we can start using <asp:ToolkitScriptManager in Sharepoint designer, without actually adding any reference on top of the master page. There are more settings you need to add in web.config, refer to Jan Tielen's blog post. Beware of his version numbers as the new version should be 3.0.++.

After solving that, I tried refreshing Sharepoint, then it gave me another error! This time, a never seen before:

could not load type 'system.web.ui.scriptreferencebase' from assembly 'system.web.extensions, version=, culture=neutral, publickeytoken=31bf3856ad364e35'.

After a bit of googling, it seems like this was because .NET 3.5 framework SP 1 had not been installed on my machine. After installing it, the error was gone.

Then, to use Ajax Controls, I just drag and drop the control onto my page (web part), and Visual Studio will add the reference on top of the page for me:

<%@ Register Assembly="AjaxControlToolkit, Version=3.0.31106.0, Culture=neutral, 
PublicKeyToken=28f01b0e84b6d53e" Namespace="AjaxControlToolkit.HTMLEditor" 
TagPrefix="asp" %>



If you think this post is useful, please recommend me at the bottom of the page. ;)