J
Jon Davis
This is always returning True, even when fields are empty. Why?
private bool ValidatePageOne() {
bool ret = true;
foreach (Control ctrl in PageOnePanel.Controls) {
if (ctrl.GetType().IsSubclassOf(typeof(BaseValidator))) {
((BaseValidator)ctrl).Validate();
if (!((BaseValidator)ctrl).IsValid)
ret = false;
}
}
return ret;
}
I should note:
Before doing this manually (using the regular page validation instead) it
worked fine. Also, I am stepping through the code and the Validator controls
are being found and Validate() is being run. Some of these are
RequiredFieldValidators. But the textboxes they are associated with are
empty, and yet IsValid is returning True! Why?
Jon
private bool ValidatePageOne() {
bool ret = true;
foreach (Control ctrl in PageOnePanel.Controls) {
if (ctrl.GetType().IsSubclassOf(typeof(BaseValidator))) {
((BaseValidator)ctrl).Validate();
if (!((BaseValidator)ctrl).IsValid)
ret = false;
}
}
return ret;
}
I should note:
Before doing this manually (using the regular page validation instead) it
worked fine. Also, I am stepping through the code and the Validator controls
are being found and Validate() is being run. Some of these are
RequiredFieldValidators. But the textboxes they are associated with are
empty, and yet IsValid is returning True! Why?
Jon