Reputation: 11350
I've been searching Google for the past couple of hours to try an find a way of returning all Validators relating to an input control. Maybe I'm phrasing incorrectly or its not possible.
I know that there is a collection of validators accessible via Page.Validators, but what I want to do is something like this:
var myValidators = Page.Validators.Where(x => x.ControlToValidate = "abcdef");
Any ideas?
Upvotes: 4
Views: 68
Reputation: 25211
Page.Validators
holds a collection of IValidator
, but most validators derive from BaseValidator
, which has the ControlToValidate
property, so you can do this:
var myValidators = Page.Validators.OfType<BaseValidator>
.Where(x => x.ControlToValidate == "abcdef");
Upvotes: 5