Click here to Skip to main content
14,828,290 members
Articles / Web Development / ASP.NET
Technical Blog
Posted 25 Sep 2012

Stats

329.7K views
13 bookmarked

WebForms UnobtrusiveValidationMode Requires a ScriptResourceMapping for jQuery

Rate me:
Please Sign up or sign in to vote.
4.87/5 (22 votes)
28 Nov 2012CPOL
A solution to the problem

Today, while working on an ASP.NET web application in VS Express 2012 for Web, I got a strange error like this.

Error : WebForms UnobtrusiveValidationMode requires a ScriptResourceMapping for ‘jquery’. Please add a ScriptResourceMapping named jquery(case-sensitive).

Error: WebForms UnobtrusiveValidationMode requires a ScriptResourceMapping for ‘jquery’. Please add a ScriptResourceMapping named jquery (case-sensitive).

It was strange because I just added some basic components like TextBox, RequiredfieldValidator, and validation summary controls only. Later, I found a Microsoft Connect issue. And according to the Connect website, we can fix this by removing the following element from the web.config file.

XML
<add key="ValidationSettings:UnobtrusiveValidationMode" 
value="WebForms" />

But I couldn’t find this element in my web.config file. Another option to fix this issue is registering jQuery in Global.asax in the Application_Start event like this:

C#
ScriptManager.ScriptResourceMapping.AddDefinition("jquery", 
    new ScriptResourceDefinition
{
Path = "~/scripts/jquery-1.7.2.min.js",
DebugPath = "~/scripts/jquery-1.7.2.min.js",
CdnPath = "http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.4.1.min.js",
CdnDebugPath = "http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.4.1.js"
});

And it worked without any issue. Adding the following element in web.config also works.

XML
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />

You can find more about Unobtrusive JavaScript on Wikipedia.

Happy programming!

Related Content

  1. How to access page methods from jQuery
  2. Image cropping in ASP.NET with jQuery
  3. Simple AutoSuggest Textbox using jQuery
  4. System.InvalidOperationException – The length of the string exceeds the value set on the maxJsonLength property.
  5. Pass your own arguments to the ClientValidationFunction in a CustomValidator

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Anuraj Parameswaran
Technical Lead
India India
Working as Tech. Lead

My blog : dotnetthoughts.net.
You can follow me in twitter : @anuraj

Comments and Discussions

 
QuestionVote of 5 for useful info Pin
dstelow13-Sep-15 11:10
Memberdstelow13-Sep-15 11:10 
GeneralMy vote of 5 Pin
Humayun Kabir Mamun18-May-15 1:30
MemberHumayun Kabir Mamun18-May-15 1:30 
AnswerWebForms UnobtrusiveValidationMode requires a ScriptResourceMapping for jQuery Pin
Member 116674055-May-15 15:21
MemberMember 116674055-May-15 15:21 
GeneralRe: WebForms UnobtrusiveValidationMode requires a ScriptResourceMapping for jQuery Pin
Anuraj Parameswaran18-Sep-15 13:59
MemberAnuraj Parameswaran18-Sep-15 13:59 
QuestionWebForms UnobtrusiveValidationMode Pin
Amey A khedekar9-Jul-14 18:39
MemberAmey A khedekar9-Jul-14 18:39 
GeneralMy vote of 3 Pin
Kedar Kulkarni19-May-14 3:47
MemberKedar Kulkarni19-May-14 3:47 
QuestionScriptManager does not exist Pin
Kedar Kulkarni19-May-14 3:45
MemberKedar Kulkarni19-May-14 3:45 
AnswerRe: ScriptManager does not exist Pin
Anuraj Parameswaran22-May-14 19:59
MemberAnuraj Parameswaran22-May-14 19:59 
GeneralRe: ScriptManager does not exist Pin
Kedar Kulkarni27-May-14 5:07
MemberKedar Kulkarni27-May-14 5:07 
GeneralRe: ScriptManager does not exist Pin
Anuraj Parameswaran28-May-14 19:39
MemberAnuraj Parameswaran28-May-14 19:39 
QuestionI tried this solution but now the RequiredField validator message appears in black instead of red. Pin
Member 107385869-Apr-14 22:08
MemberMember 107385869-Apr-14 22:08 
GeneralMy vote of 5 Pin
Bharat Mallapur24-Oct-13 21:18
MemberBharat Mallapur24-Oct-13 21:18 
Questionhow to add Global.asax Pin
nisar mohamed25-Feb-13 5:20
Membernisar mohamed25-Feb-13 5:20 
Questionfrnds...I am struggling to apply this line in Webconfig Pin
nisar mohamed25-Feb-13 5:12
Membernisar mohamed25-Feb-13 5:12 
QuestionThanks Pin
Jixian2-Jan-13 23:41
MemberJixian2-Jan-13 23:41 
QuestionReolved differently Pin
Gaurang Naik20-Nov-12 22:16
MemberGaurang Naik20-Nov-12 22:16 
AnswerRe: Reolved differently Pin
Vijay Kanda27-Nov-12 21:15
MemberVijay Kanda27-Nov-12 21:15 
AnswerRe: Reolved differently Pin
Anuraj Parameswaran27-Nov-12 21:53
MemberAnuraj Parameswaran27-Nov-12 21:53 
GeneralRe: Reolved differently Pin
Praveen Tvpm5-Apr-13 5:43
MemberPraveen Tvpm5-Apr-13 5:43 
AnswerRe: Reolved differently Pin
The Stonx21-Mar-13 9:47
MemberThe Stonx21-Mar-13 9:47 
AnswerRe: Reolved differently Pin
Uthman Rahimi26-Nov-14 2:36
professionalUthman Rahimi26-Nov-14 2:36 
Questionajax.microsoft.com renamed to ajax.aspnetcdn.com Pin
dwatkins@dirq.net12-Nov-12 4:27
Memberdwatkins@dirq.net12-Nov-12 4:27 
AnswerRe: ajax.microsoft.com renamed to ajax.aspnetcdn.com Pin
Alexandre Toledo Perez13-Feb-13 7:30
MemberAlexandre Toledo Perez13-Feb-13 7:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.