简体   繁体   English

ASP.Net + MVC + VS 2008

[英]ASP.Net + MVC + VS 2008

Can anyone advise what is the best way of client and server side validation. 任何人都可以建议客户端和服务器端验证的最佳方法是什么。

Either we go for Data Annotation if it support with VS2008. 如果它支持VS2008,我们要么选择数据注释。 Or go with Jquery ... 或者使用Jquery ...

Can anybody guide me as well any example, link is appreciated. 任何人也可以指导我任何示例,链接表示赞赏。

xVal is highly recommended: 强烈建议使用xVal:

http://xval.codeplex.com/ http://xval.codeplex.com/

http://blog.codeville.net/2009/01/10/xval-a-validation-framework-for-aspnet-mvc/ http://blog.codeville.net/2009/01/10/xval-a-validation-framework-for-aspnet-mvc/

With xVal you can do both client & server side with Data annotations & jQuery or other validation engines like castle.... 借助xVal,您可以使用数据注释和jQuery或其他验证引擎(如Castle)来在客户端和服务器端进行...。

Data Annotations is a server side technology and jQuery is client side. 数据注释是服务器端技术,而jQuery是客户端。 To do both client/server validation you need both, its not a question of either/or. 要同时进行客户端/服务器验证,您既需要验证,又不是问题之一。

The simple answer is "Both!" 简单的答案是“两个!”

You want your users to have a fast, smooth UI so instant feedback is essential (unless you can guarantee that your round-trip time is ultra-fast) and saves on round-trips. 您希望您的用户拥有快速,流畅的用户界面,因此即时反馈至关重要(除非您可以保证往返时间超快)并节省往返费用。 However, you cannot guarantee that only your clients with this validated input is being posted to your server so you need to validate there as well. 但是,您不能保证仅将具有此经过验证的输入的客户发布到您的服务器,因此您也需要在此进行验证。

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

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