WebForms UnobtrusiveValidationMode requires a ScriptResourceMapping
Published: 6/8/2013 2:36:51 AM
The other day I was updating an old application that was created in Visual Studio 2010 originally and later was upgraded to Visual Studio 2012. One of the changes I made was to add the <httpRuntime targetFramework="4.5" /> element to web.config. When I tested the application after the updates, I noticed the following error:
WebForms UnobtrusiveValidationMode requires a ScriptResourceMapping for 'jquery'.
Please add a ScriptResourceMapping named jquery(case-sensitive).
The error was quite self-explanatory: I needed to add a ScriptResourceMapping named "jquery". Adding the following code to Global.asax solved the problem:
protected void Application_Start()
{
ScriptResourceDefinition srd = new ScriptResourceDefinition();
srd.Path = "~/Scripts/jquery-1.6.2.js";
ScriptManager.ScriptResourceMapping.AddDefinition("jquery", null, srd);
}