views:

146

answers:

0

In my model, I am apply Data Annotations that takes multiple values. I can get it to work at the class level but the values are not passed with I try this at the property level. My goal is to add the error at the property level, not form level.

[PropertiesMustMatch("Password", "ConfirmPassword", ErrorMessage = "...")]
public class RegModel {
     [ValidPURL("EventName", "PURLValue",ErrorMessage="Dude")]
     public string PURLValue { get; set; }
     public string Password { get; set; }
     public string ConfirmPassword { get; set; }
}

In my validation method, I define these properties in my validation class but get a null error when I try to get property my IsValid method.

PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(value);
object purlValue = properties.Find(PURLValue, true /* ignoreCase */).GetValue(value);

Any ideas?