How I can create custom attribute in Data Annotation?I want to set Control name assosiated with a property ad I don’t find any suitable attribute.
How I can do this?
thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You must extend System.ComponentModel.DataAnnotations.ValidationAttribute
K. Scott Allen (of OdeToCode) has a great example where he builds a custom “GreaterThan” attribute.
http://odetocode.com/blogs/scott/archive/2011/02/21/custom-data-annotation-validator-part-i-server-code.aspx
Here is the snippet included inline though: