Click here to Skip to main content
Click here to Skip to main content

WebForms UnobtrusiveValidationMode requires a ScriptResourceMapping for jQuery

By , 28 Nov 2012
 

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.

<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:

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.

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

You can find more about Unobtrusive JavaScript on Wikipedia.

Happy programming

License

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

About the Author

Anuraj Parameswaran
Technical Lead Accel Frontline Ltd
India India
Member
Working as Tech. Lead in Accel Frontline Ltd.
 
My blog : dotnetthoughts.net.
You can follow me in twitter : @anuraj

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
Questionhow to add Global.asaxmemberMember 986304725 Feb '13 - 5:20 
Questionfrnds...I am struggling to apply this line in WebconfigmemberMember 986304725 Feb '13 - 5:12 
QuestionThanksmemberJixian2 Jan '13 - 23:41 
QuestionReolved differentlymemberGaurang Naik20 Nov '12 - 22:16 
AnswerRe: Reolved differentlymemberVijay Kanda27 Nov '12 - 21:15 
Gaurang,
Thanks a lot... I just ran into the same issue... as you suggested , I changed the
targetFramework to 4 from 4.5. Issue Resolved.
AnswerRe: Reolved differentlymemberAnuraj Parameswaran27 Nov '12 - 21:53 
GeneralRe: Reolved differently [modified]memberpraleesha5 Apr '13 - 5:43 
AnswerRe: Reolved differentlymemberThe Stonx21 Mar '13 - 9:47 
Questionajax.microsoft.com renamed to ajax.aspnetcdn.commemberdirq12 Nov '12 - 4:27 
AnswerRe: ajax.microsoft.com renamed to ajax.aspnetcdn.commemberAlexandre Toledo Perez13 Feb '13 - 7:30 

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

Permalink | Advertise | Privacy | Mobile
Web03 | 2.6.130516.1 | Last Updated 28 Nov 2012
Article Copyright 2012 by Anuraj Parameswaran
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid