2

I upgraded a WebForms project to .net 4.5, and received this error:

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

I'd like to enable UnobtrusiveValidation, but I'm using Combres for Javascript resources, so I don't want the ScriptManager to try to download it again. Is it possible to tell the ScriptManager to just trust me that it will be loaded? In other words, I want to add a mapping for "jquery" that does nothing. It's apparently not possible to add a ScriptResourceDefinition with a name but no paths. Is there any other way?

Jerph
  • 4,572
  • 3
  • 42
  • 41

2 Answers2

2

As far as I can tell the answer is no.

This question has been asked on http://connect.microsoft.com/VisualStudio/feedback/details/735928/in-asp-net-web-application-visual-basic-the-requiredfieldvalidator-doest-work and on http://forums.asp.net/t/1850831.aspx/1 with no answers.

As a quick and nasty workaround to this problem I have added an empty file called DummyJQuery.js into the solution put the code below into application_start:

 Dim jQuery As New ScriptResourceDefinition()
 jQuery.Path = "~/js/DummyJQuery.js"
 jQuery.DebugPath = "~/js/DummyJQuery.js"
 ScriptManager.ScriptResourceMapping.AddDefinition("jquery", jQuery)
user1069816
  • 2,763
  • 2
  • 26
  • 43
0

Answer described here: http://www.codeproject.com/Articles/465613/WebForms-UnobtrusiveValidationMode-requires-a

martinwnet
  • 571
  • 2
  • 4
  • 10
  • Sorry, my question was unclear and I've edited it. That page suggests that I add a jquery reference to the ScriptManager, but I don't want it to download another copy of jQuery - I already load it as part of my Combres Resource. – Jerph Oct 12 '12 at 15:33
  • Have you already tried this solution? I would've presumed it just added a reference to JQuery so the script manager knew about it (i.e. not download multiple copies). – martinwnet Oct 12 '12 at 15:36
  • I have, it adds script tags for the cdn version, a check for whether it's loaded, and for the local version if that fails. Honestly, if it would also do a check for jQuery before doing the *CDN* version, it'd be fine. – Jerph Oct 12 '12 at 15:57