In this article I will explain with an example, how to resolve the following error.
WebForms UnobtrusiveValidationMode requires a ScriptResourceMapping for 'jquery'. Please add a ScriptResourceMapping named jquery(case-sensitive).
Error
The following error occurs, when you are using ASP.Net RequiredFieldValidator control in .Net Framework 4.5 and above.
Server Error in '/' Application.
WebForms UnobtrusiveValidationMode requires a ScriptResourceMapping for 'jquery'. Please add a ScriptResourceMapping named jquery(case-sensitive).
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: WebForms UnobtrusiveValidationMode requires a ScriptResourceMapping for 'jquery'. Please add a ScriptResourceMapping named jquery(case-sensitive).
Solution
This error can be solved by setting the UnobtrusiveValidationMode flag to None.
You can set UnobtrusiveValidationMode in the following ways.
1. Using Web.Config
You will need to add UnobtrusiveValidationMode to None in the appSettings section inside Web.Config file.
<appSettings>
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
</appSettings>
2. Using Code Behind
Inside the Page Load event handler, set the value of the UnobtrusiveValidationMode property of the page to None.
C#
protected void Page_Load(object sender, EventArgs e)
{
this.UnobtrusiveValidationMode = System.Web.UI.UnobtrusiveValidationMode.None;
}
VB.Net
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
Me.UnobtrusiveValidationMode = System.Web.UI.UnobtrusiveValidationMode.None
End Sub
3. Using Page Directive
You can also set UnobtrusiveValidationMode in the @Page Directive of the page.
<%@Page Language="C#" AutoEventWireup="true" UnobtrusiveValidationMode="None" %>