Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Participant
959 Points
193 Posts
May 04, 2012 05:18 AM|LINK
You can try making your view model of type IValidatableObject and do a custom validaton
public class User: IValidatableObject { [DisplayName("User Name")] public string UserName { get; set; } public IEnumerable<ValidationResult> Validate( ValidationContext context ) { if (Conditions)) { yield return new ValidationResult("Error Message" ); } } }
gopakumar.r
Participant
959 Points
193 Posts
Re: Help, how to avoid repeated code.
May 04, 2012 05:18 AM|LINK
You can try making your view model of type IValidatableObject and do a custom validaton
public class User: IValidatableObject { [DisplayName("User Name")] public string UserName { get; set; } public IEnumerable<ValidationResult> Validate( ValidationContext context ) { if (Conditions)) { yield return new ValidationResult("Error Message" ); } } }Gopakumar
| Please click “Mark as Answer” on the post(s) if it helps |