Tuesday, October 8, 2013

WebForms UnobtrusiveValidationMode requires a ScriptResourceMapping for 'jquery'. Please add a ScriptResourceMapping named jquery(case-sensitive)

If you receive the WebForms UnobtrusiveValidationMode requires a ScriptResourceMapping for 'jquery' error, put the following lines of code in the Appliction_Start method in the Global.asax.cs file

        protected void Application_Start(object sender, EventArgs e)
{
string jqueryVersion = "1.8.0";

System.Web.UI.ScriptManager.ScriptResourceMapping.AddDefinition("jquery",
new System.Web.UI.ScriptResourceDefinition
{
Path = "~/Scripts/jquery-" + jqueryVersion + ".min.js",
DebugPath = "~/Scripts/jquery-" + jqueryVersion + ".js",
CdnPath = "http://ajax.aspnetcdn.com/ajax/jQuery/jquery" + jqueryVersion + ".min.js",
CdnDebugPath = "http://ajax.aspnetcdn.com/ajax/jQuery/jquery" + jqueryVersion + ".js",
CdnSupportsSecureConnection = true,
LoadSuccessExpression = "Window.jquery"

});
}


The above lines of code registers the jQuery library with the ScripManager. This will get rid of the error, you can do the same this with jQueryUI library.