c# - Get encompassing class, then access a property of it inside custom attribute -
I am using ASP.NET MVC through custom attributes / data annotations on my model and implement custom verification I am doing
Is it possible to use the property on the original class of the object inside my custom attribute?
public class MyModel {[MyCustomValidator} public string var1 {get; Set;} public string var2 {get; Using asp.net mvc public class MyCustomValidatorAttribute: Validation attribute {Public Bull override IsValid (object value) {// Access anyway var2 in MyModel}}
So basically, check the verification of other assets for a specific value. I tried to pass the value of var2
as the parameter of MyCustomValidator
but that does not work
No, basically. After a prey through a reflector, you have only been examining the member's value - which does not have any item or member / information of the property / region / member also.
I agree that it is very limited and frustrating, but it seems that it has been fixed in 4.0 - on my last answer sign , but a surcharge in 4.0 Who accepts this information, who provides this information.
Comments
Post a Comment