21

What are the differences between ScriptManager and ToolkitScriptManager? I found only one convincing reason: that ToolkitScriptManager improves page performance. If so why use ScriptManager?

animuson
  • 53,861
  • 28
  • 137
  • 147
Devjosh
  • 6,450
  • 4
  • 39
  • 61

1 Answers1

28

First of all: if you use ASP.NET 3.5 and controls from AJAX Control Tookit then you must use the ToolkitScriptManager, rather than the ASP.NET ScriptManager. This limitation according to the fact that toolkit script manager adds updated Ajax scripts and without that most of the controls from Ajax Control toolkit library will not work.

If you using ASP.NET 4.0 (4.5) than you have choice to use ScriptManager or ToolkitScriptManager.

Basically the main feature of the ToolkitScriptManager is that it can combine js resource added to page using ScriptReference collection. These js files should be embedded to assembly and for this Assembly ScriptCombine assembly attribute should be added. The main problem here is that you can't control how scripts are combined and after you will try to combine your own scripts you can have a lot of problems (I had experience using this feature and as a result we rejected combining of our scripts using this approach).

The main point here is that currently standard script manager has ability to combine scripts using composite script collection. This feature is more flexible and it is more easy to control how scripts are combined on your pages. The more information can be found using the following link: http://weblogs.asp.net/infinitiesloop/archive/2009/11/23/asp-net-4-0-scriptmanager-improvements.aspx.

Also, note that as far as I remember if you using ToolkitScriptManager then you will not be able to use CompositeScript feature, even to take in account that the ToolkitScriptManager derives from ScriptManager.

So, in ASP.NET 4.0 the difference is not so big, and it is better to avoid using ToolkitScriptManager. The main reason is that using standard CompositeScript feature you have more control on how scripts are combined and can optimized rendering of the page.

For ASP.NET 3.5 you don't have choice if you want to use controls from Ajax Control Toolkit library.

Edit

With the latest changes in ajax control toolkit library they proceed to update MS Ajax scripts and that's why some of the controls can't work without adding ToolkitScriptManager.

Maxim Kornilov
  • 5,675
  • 1
  • 24
  • 35
  • If you using Ajax Control Toolkit Controls - you should replace your "ScriptManager" to the "ToolkitScriptManager". I know that in simple cases all will work without making that replacement but in the more deep cases such as putting ajax-ctk control into a user-control or a master-page problems may start coming.. and it will take precious time to originate them to the script manager which you didn't replace! – G.Y Aug 21 '13 at 04:59
  • @G.Y could you please clarify in details why it is necessary to replace the "ScriptManager" to the "ToolkitScriptManager" if you are developing you application using ASP.NET 4.0 or higher. I developed a very large amount of custom control with client side support which are based on API from Ajax Control Toolkit and that's why some time ago I spent quite enough time to review the sources of the Ajax Control Tookit lib. And my experience of supporting several quite big business Web Applications which are based on ASP.NET web forms tells me that everything works without "ToolkitScriptManager". – Maxim Kornilov Aug 22 '13 at 13:14
  • Maxim, I need a lot of room to explain it down to the details.. for now just create a new project add the CTK and create a page with MultiHandleSliderExtender - with the basic script manager = all will work.. now make a usercontrol of it and put it in the page.. will not work :) replace script manager to CTK script manager - all working again.. in short the ctk script manager bring updates with it which may be a "must" to some ctk controls. – G.Y Aug 22 '13 at 18:32
  • 1
    "First of all: Pages using controls from AJAX Control Tookit .NET 3.5 must use the ToolkitScriptManager, rather than the ASP.NET ScriptManager." We've been using the AjaxControlToolkit controls for a number of years and still use ScriptManager. The application still works without ToolkitScriptManager so your statement isn't entirely true. – Neil Jan 24 '14 at 16:35
  • @Neil It seems that I didn't specify what I want correctly. The more correct phrase should be "First of all: if you use ASP.NET 3.5 and controls from AJAX Control Tookit then you must use the ToolkitScriptManager, rather than the ASP.NET ScriptManager." I also use ScriptManager and Ajax Control Toolkit library for several production projects on .Net Framework 4.0. So, I update my answer. – Maxim Kornilov Mar 08 '14 at 19:53