Ajax Control Toolkit – JavaScript Runtime Error

So here I was on a Friday afternoon with another doozy of an error. I recently needed to make a modification to an existing web application we wrote. The original developer had left the company and I had to take this project over for the change. The forms make use of Ajax, so I duly went ahead and installed the Ajax Control Toolkit via NuGet. I then started seeing the following error: ‘JavaScript runtime error: Unable to get property ‘UI’ of undefined or null reference’. I saw that a modal popup caused this error. I wasn’t too surprised as I had expected some errors, but the solution however did surprise me.

JavaScript Runtime Error

Well there is not much to say about this solution. Here is the screen that pops up.

JavaScript Runtime Error

Some sources on the Internet said that one needs to set the CombineScripts property to False, but I didn’t think that would be a solution, but rather a workaround. Then there was a solution offered by masterw that worked like a charm.

replace

<asp:ScriptManager ID=”ScriptManager1″ runat=”server”>
</asp:ScriptManager>

with

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

After I did this, the error stopped and my pages (and modal popup dialogs) started working again. If anyone has a nice explanation as to why this worked, please let me know in the comments.

Dirk Strauss

As a seasoned software developer with a long-standing career in C# and Visual Studio, I have had the privilege of working with a number of companies and learning from some of the most talented individuals in the industry. In addition to my professional experience, I have authored multiple books on topics such as C#, Visual Studio, and ASP.NET Core. My passion for programming is unwavering, and I am dedicated to staying current with the latest technology and sharing my expertise with others.