Tutorial by Examples

Validation attributes can be used to easily configure model validation. public class MyModel { public int id { get; set; } //sets the FirstName to be required, and no longer than 100 characters [Required] [StringLength(100)] public string FirstName { get; set; } } Th...
If the built in attributes are not sufficient to validate your model data, then you can place your validation logic in a class derived from ValidationAttribute. In this example only odd numbers are valid values for a model member. Custom Validation Attribute public class OddNumberAttribute : Valid...

Page 1 of 1