简体   繁体   中英

Using ASP.NET MVC 3 **WITHOUT** jQuery

I need to write an application in ASP.NET MVC, but for corporate reasons I can't use jQuery. I have heard that you can "turn off" jQuery and that ASP.NET controls like TextBoxFor will fall back to using Microsoft's older JS libraries. But I haven't found any detailed information on how to do this.

Anyone have experience with this approach? Any pointers?

ASP.NET MVC does not require jQuery. The MVC3 project templates include it in _Layout.cshtml because many developers prefer it. You can remove it.

It does use jQuery Validation by default, however, but you can use the Microsoft Ajax MVC2 libraries instead.

If you remove jQuery scripts, you will be unable to use the jQuery/Unobtrusive MVC 3 validation.

Use the MS scripts and corresponding validation functionality instead:

_Layout.cshtml:

"~/Scripts/MicrosoftAjax.js"

"~/Scripts/MicrosoftMvcValidation.js"

That's all.

By the way, why cannot you use the jQuery in your project?

It's all down to the adapters that you decide to include from the default script folders. If you don't want to use Jquery include the other adapter files.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM