Is there an easy way to search for validators related to input control?

I searched Google for the last couple of hours to try and find a way to return all validators associated with the input control. Maybe I'm wrongly worded or it's impossible.

I know that there is a collection of validators available through page.Validators, but I want to do something like this:

var myValidators = Page.Validators.Where(x => x.ControlToValidate = "abcdef"); 

Any ideas?

+4
source share
1 answer

Page.Validators contains a set of IValidator , but most validators get from BaseValidator , which has the ControlToValidate property, so you can do this:

 var myValidators = Page.Validators.OfType<BaseValidator> .Where(x => x.ControlToValidate == "abcdef"); 
+5
source

Source: https://habr.com/ru/post/1492314/


All Articles