Mohit Mohit - 8 days ago 4
C# Question

AjaxControlToolkit Error: AjaxControlToolkit requires ASP.NET Ajax 4.0 scripts. Ensure the correct version of the scripts are referenced

I am using Visual Studio 2012 trial. I created a Sample Application and added AjaxControlToolkit reference using NuGet to latest build of toolkit. I am already using Toolscriptmanager on my webpage under form Tag.

Platform Details:


  • .NET Framework 4.5

  • Language: c#

  • IIS 6.1

  • OS: Windows 7 64 Bit



Below is the code sample of my aspx page.

<form id="form1" runat="server">
<ajaxToolkit:ToolkitScriptManager ID="sm" EnableCdn="true" runat="server"> </ajaxToolkit:ToolkitScriptManager>
<asp:TextBox runat="server" ID="txtEmail" CssClass="stcInputText rounded-corners"></asp:TextBox>
<ajaxToolkit:MaskedEditExtender TargetControlID="txtEmail" Mask="9,999,999.99" MessageValidatorTip="true" OnFocusCssClass="MaskedEditFocus" OnInvalidCssClass="MaskedEditError" MaskType="Number" InputDirection="RightToLeft" AcceptNegative="Left" DisplayMoney="Left" ErrorTooltipEnabled="True"/>
</form>


Web Config Configuration

<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<pages >
<namespaces>
<add namespace="System.Web.Optimization" />
</namespaces>
<controls >
<add assembly="Microsoft.AspNet.Web.Optimization.WebForms" namespace="Microsoft.AspNet.Web.Optimization.WebForms" tagPrefix="webopt" />
<add tagPrefix="ajaxToolkit" assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" />
</controls>
</pages>
</system.web>


Still I am getting:


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 ToolkitScriptManager in AjaxControlToolkit.dll


Please help me to sort out this issue.

As per suggestion I have changed webconfig and project properties to .NET 4.0.

I tried to change all projects to 4.0. It worked once, but now I am getting the same error again. Now web config looks

<compilation debug="true" targetFramework="4.0" >
</compilation>
<httpRuntime requestValidationMode="2.0" maxRequestLength="10000" />
<pages controlRenderingCompatibilityVersion="4.0" clientIDMode="AutoID">
<controls>
<add tagPrefix="ajaxToolkit" assembly="AjaxControlToolkit" namespace="AjaxControlToolkit"/>
</controls>
</pages>


Project Property Target to
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>

Answer

Actually If you convert your project from .net 4.5 to 4.0. it still refers some library of 4.5. Thats why it don't work. You either need to recreated project in 4.0 framework or Delete existing library and refer them from 4.0 framework.