ASP.NET MVC3 Model Validation DataAnnotations to do less than or equal to another property with client side validation?

Have a look at this article. It explains how to extend the ASP. NET MVC model validation to support cross-field validation: Extending ASP.NET MVC’s Validation blogs.msdn.com/b/mikeormond/archive/2010....

Robert Harvey's answer put me on the right path but it is possible with ASP. NET MVC3 to quite simply override the validation using the following pattern: public class LessThanOrEqualToPropertyAttribute : ValidationAttribute, IClientValidatable { public string OtherProperty { get; set; } public override bool IsValid(object value) { return true; } protected override ValidationResult IsValid(object value, ValidationContext validationContext) { if (value! = null) { PropertyInfo propertyInfo = validationContext.ObjectType.

GetProperty(OtherProperty); var otherValue = propertyInfo.GetGetMethod(). Invoke(validationContext. ObjectInstance, null); if ((int)otherValue GetClientValidationRules(ModelMetadata metadata, ControllerContext context) { var rule = new ModelClientValidationRule { ValidationType = "lessthanorequaltoproperty", ErrorMessage = FormatErrorMessage(ErrorMessage), }; rule.

ValidationParameters. Add("otherproperty", OtherProperty); yield return rule; } } This wasn't exactly clear from the various conflicting documentation I found.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions