Custom Validation Attribute MVC2

后端 未结 3 1892
[愿得一人]
[愿得一人] 2021-01-02 13:53

I have a custom validation attribute which checks to see if two properties have the same values or not (like password and retype password):

[AttributeUsage(A         


        
3条回答
  •  误落风尘
    2021-01-02 14:06

    I'm not sure why your code doesn't work, but through GetType() you can get the expected result:

    var property = value.GetType().GetProperty(CompareProperty);
    var comparePropertyValue = property.GetValue(value, null).ToString();
    

提交回复
热议问题