Unable to get property value "unobtrusive": object is null or undefined

When I run my code, I get this error:

Unable to get value of the property 'unobtrusive': object is null or undefined 

It would be fine, but I add all the necessary jquery stuff:

 jquery.validate-vsdoc.js jquery.validate.js jquery.validate.min.js jquery.validate.unobtrusive.js jquery.validate.unobtrusive.min.js jquery.unobtrusive-ajax.js jquery.unobtrusive-ajax.min.js 

I upload this to my main form:

 @Scripts.Render("~/bundles/jquery") @Scripts.Render("~/bundles/jqueryui") @Scripts.Render("~/bundles/jqueryval") 

And my bundle configuration has:

 bundles.Add(new ScriptBundle("~/bundles/jquery").Include( "~/Scripts/jquery-{version}.js")); bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include( "~/Scripts/jquery-ui-{version}.js")); bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include( "~/Scripts/jquery.unobtrusive*", "~/Scripts/jquery.validate*")); 

My Script folder has all the related files.

Why am I getting this error? Comment, if you need to see any file, and I will gladly publish it

EDIT:

Scripts are loading (I checked) This line gives an error:

 jQuery.validator.unobtrusive.prototype.parse.call(this, selector); 

ERROR:

 SCRIPT5007: Unable to get value of the property 'unobtrusive': object is null or undefined 
+6
source share
4 answers

Found a problem.

I had another partial view that added the script "~ / Scripts / jquery ..."

So, I had the package in the main view, and this one was in the partial menu, which has always been rendering. It seems that only the latter has been reviewed, and Unobtrusive has not been added there. Removing it from the partial view and leaving only one in the main view allowed it.

Thanks for the guesswork.

+8
source

I got it for something much more than a bone mind. I had jquery.validate.unobtrusive.js before jquery.validate.min.js on my page.

Just move the confirmation over validate.unobtrusive validation to fix the problem.

+3
source

I received this error message for another reason, therefore, although I would share.

We use the Microsoft CDN to service the jquery.validate.min.js file, and our client used a filter from the asp.netcdn.com to prevent it from loading.

Thus, getting a CDN whitelist or changing a CDN will be a problem. In fact, we must have a backup so that it serves the local version if the CDN was not available, but we have not yet implemented it.

+2
source

What Junkie code means to say that you added the hated javacript activation key to web.config.

You need to add this to appSettings:

 <appSettings> <add key="ClientValidationEnabled" value="true" /> <add key="UnobtrusiveJavaScriptEnabled" value="true" /> </appSettings> 
-1
source

Source: https://habr.com/ru/post/946705/


All Articles