protected override void OnLoadComplete(EventArgs e)
{
foreach (var validator in Page.Validators)
{
//do something
}
base.OnLoadComplete(e);
}
Why does var validator2 = Page.Validators[1].ControlToValidate not work? It inherits the property but I can’t get access to it.
See this image – http://tinypic.com/r/14v5r0y/7
Also, is this the right place in the page cycle to get access to the validation errors?
The
ControlToValidateproperty returns a string, pertaining to the ID of the control that is being validated. Is that what you’re looking for?To get the actual validator, I believe you’d want something like this: