public enum ProductQuantityType { Weight开发者_如何学Go = 1, Volume = 2, Custom = 0 } This fails [MetadataType(typeof(ProductMetaData))]
I have an Asp.NET MVC application in which I use data annotations to add validation to some fields: [Required]
Is it best practice to put data validation annotations in the Model or View Model? What are the advantages/disadvantages of one approach over the other?
So I have been using data annotations for my validation in an MVC project and they seem to work in most scenarios.
I have some code that enumerates over an object and records any errors it has based on its ValidationAttribute(s).
How can I use DataAnnotations to validate that at least one of these fields are filled in? public string Name { get; set; }
There\'s a way to set the default resource to the data annotations validations? I don\'t wanna make something like this:
Can anyone tell me how to use DataType.Custom in ASP.NET MVC 开发者_运维知识库2?Don\'t use DataType.Custom.
I am using data annotations to validate an emailaddress. To show an error message when the emailaddress is not valid, I use a RESX file called ErrorMessages.
This question already has answers here: ASP.NET MVC - Custom validation message for value types (7 answers)