Monday, July 8, 2013

How to do server side validation for ASP.NET MVC Model?

Implement IValidatableObject interface inside model :

public System.Collections.Generic.IEnumerable Validate(ValidationContext validationContext)
 {
            if(true)
            {
                yield return new ValidationResult("error message", new string[] { "Validated Object Name" });                
            }
 }


http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.ivalidatableobject.validate.aspx

No comments:

Post a Comment