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 th开发者_运维百科e validation errors?
The ControlToValidate
property 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:
var validator = (BaseValidator)Page.Validators[0];
string controlToValidate = validator.ControlToValidate;
精彩评论