ASP.NET Ajax :: Script Manager vs ToolkitScriptManager

I have noticed that .NET 4.0 has come up with a major changes in the Application Development in .NET platform.

Recently for practice me and my friends has downloaded the latest AjaxControlToolkit from codeplex here.   There were two set of libraries for download one for .NET 4.0 and another for .NET 3.5. Since we are mostly doing development in Visual Studio 2008, we have downloaded the AjaxControlToolkit.Binary.NET35.zip .

Cool. After downloaded I start of with AutoComplete extender, when I compiled the web application, i notice a warning message been displayed by the compiler.

 ”Microsoft JScript runtime error: AjaxControlToolkit requires ASP.NET Ajax 4.0 scripts. Ensure the correct version of the scripts are referenced. If you are using an ASP.NET ScriptManager, switch to the AjaxScriptManager in System.Web.Ajax.dll, or use the ToolkitScriptManager in AjaxControlToolkit.dll.”

I wondered where this ToolkitScriptManager came?.  I didnt noticed it previously, we always used the ASP.NET Script manager even for the AjaxControlToolkit.  So i was a kinda curious to know what special with ToolkitScriptManager. 

But from my little understanding about the ASP.NET Ajax 4.0 and CDN (Content Delivery Network) support, i felt might be the recent move by microsoft to separate the concerns. The ToolkitScriptManager will register/load only the client side libraries needed by the AjaxControlToolkit Controls. I want to make sure what is special about it.

So i went on searching for some good information in google. Voila!!! I got it.. It’s a blog article(Script Manager vs Toolkit Script Manager) by Alexander Turlov  (link to his blog here).

When i checked the blog date it was from May 23 2008, so it was there in the beginning itself, but i was kept myself been dark about this information. 

The  notable point is, it was there from the beginning, but now the latest DLL (Build 40412 , Released Apr 12 2010, Stable Version) forcing the developer to start using the ToolkitScriptManager. Reason i believe as i mentined previously, CDN(Content Delivery Network) support may be.  Latest Microsoft Ajax 4.0 Libraries can be delivered through the CDN, to reduce the burden to the web server.  So Ajax Libraries would be delivered through CDN and AjaxControlToolkit libraries only will be delivered from the Web Server where the site is hosting, when we using AjaxControlToolkit.

Also there are asumptions that the Build 40412 has been compiled against the ASP.NET Ajax Library 4.0.  You can avoid this error by consuming the Ajax 4.0 library directly from Microsoft CDN.  

Just like the given below might solve the problem temporarily.


  <asp:ScriptManager ID="ScriptManager1" runat="server">
    <Scripts>
      <asp:ScriptReference Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        Name="MicrosoftAjax.js" Path="http://ajax.microsoft.com/ajax/4.0/1/MicrosoftAjax.js" />
      <asp:ScriptReference Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        Name="MicrosoftAjaxWebForms.js" Path="http://ajax.microsoft.com/ajax/4.0/1/MicrosoftAjaxWebForms.js" />
    </Scripts>
  </asp:ScriptManager>

OR

Use


<asp:ToolkitScriptManager ID="ScriptManager1" runat="server">

</asp:ToolkitScriptManager>

This is just a work around might work for some people, some might not. But it’s recommended to use the ToolkitScriptManager, to avoid such errors. When microsoft is providing us specific control set, why don’t we use it. Use recommended settings and avoid troubles.

PS: I am not sure this is a right guess. But i welcome your debate on this blog.

For Beginners I am quoting from Alexandar’s Blog

ScriptManager is a special ASP.NET server control that should be placed on a page before you can use any of AJAX.NET enabled controls. The same rule is true for the AJAX Control Toolkit controls: they all require a ScriptManager on the page. While AJAX Control Toolkit controls work perfectly fine with the standard ASP.NET ScritpManager the Toolkit includes its own version of the ScriptManager called ToolkitScriptManager that inherits from ScriptManager and is meant to improve some of the ScriptManager’s behaviors in particular how it renders out behavior JS scripts.

Read the blog article(Script Manager vs Toolkit Script Manager) by Alexander Turlov  (link to his blog here).

5 Comments

  1. Pingback: Tweets that mention Script Manager vs ToolkitScriptManager » Code Name "NitRiX Reloaded" -- Topsy.com

Other times, you're doing some piece of work and suddenly you get feedback that tells you that you have touched something that is very alive in the cosmos. Share your feedback on this blog, it will help me improve it a lot..