简体   繁体   English

使用ASP.NET MVC 3 **没有** jQuery

[英]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. 我需要在ASP.NET MVC中编写一个应用程序,但出于公司原因我不能使用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. 我听说你可以“关闭”jQuery,像TextBoxFor这样的ASP.NET控件将回归到使用微软较旧的JS库。 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. ASP.NET MVC不需要jQuery。 The MVC3 project templates include it in _Layout.cshtml because many developers prefer it. MVC3项目模板在_Layout.cshtml包含它,因为许多开发人员更喜欢它。 You can remove it. 你可以删除它。

It does use jQuery Validation by default, however, but you can use the Microsoft Ajax MVC2 libraries instead. 但是,它默认使用jQuery Validation,但您可以使用Microsoft Ajax MVC2库。

If you remove jQuery scripts, you will be unable to use the jQuery/Unobtrusive MVC 3 validation. 如果删除jQuery脚本,则无法使用jQuery / Unobtrusive MVC 3验证。

Use the MS scripts and corresponding validation functionality instead: 请改用MS脚本和相应的验证功能:

_Layout.cshtml: _Layout.cshtml:

"~/Scripts/MicrosoftAjax.js"

"~/Scripts/MicrosoftMvcValidation.js"

That's all. 就这样。

By the way, why cannot you use the jQuery in your project? 顺便说一句,为什么你不能在你的项目中使用jQuery?

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. 如果您不想使用Jquery包含其他适配器文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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