如何怀疑自定义[必需]属性 [英] How to wright custom [Required] attribute
本文介绍了如何怀疑自定义[必需]属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要一个自定义属性,它支持Asp.net mvc 4中的客户端和服务器端验证。
我没有得到如何为[Required]属性找到它,有人可以提供一些信息。
要求我需要提供自定义错误消息,通过调用模型函数将其放在数据库中。
但是[必需(ErrorMessages ='这里我不能调用函数')]
I need a custom attribute which supports client and server side validation in Asp.net mvc 4.
i'm not getting how to right it for [Required] attribute ,can some one can provide some info.
Requirement is i need to give custom error messages ,which are placed in data base by calling a model function.
but [Required(ErrorMessages='here i'm not able to call a function')]
推荐答案
我想你可以创建一个使用自定义数据注释属性自定义逻辑检查以下URL
http://www.c-sharpcorner.com/UploadFile/abhikumarvatsa/custom-data-annotations-or-custom-validation-attributes-in-m/ [ ^ ]
http://stackoverflow.com/questions/3413715/how-to-create-custom-data-annotation-validators [ ^ ]
希望这会对你有所帮助
I think you can create a customize logic with a custom data annotation attribute check the below URLs
http://www.c-sharpcorner.com/UploadFile/abhikumarvatsa/custom-data-annotations-or-custom-validation-attributes-in-m/[^]
http://stackoverflow.com/questions/3413715/how-to-create-custom-data-annotation-validators[^]
Hope this will help you
这可能也有帮助 -
在MVC 3中创建自定义验证属性 [ ^ ]
-KR
This might help too-
Creating Custom Validation Attribute in MVC 3[^]
-KR
这篇关于如何怀疑自定义[必需]属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文