Manual Validate call always returns IsValid=true

  • Thread starter Thread starter Jon Davis
  • Start date Start date
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
 
I've tested that exact code with a required field, and a compare validator,
on one text field (within a panel), and it worked fine for me. I would look
elsewhere for the problem you are experiencing.

--Michael
 
Thanks


Michael said:
I've tested that exact code with a required field, and a compare validator,
on one text field (within a panel), and it worked fine for me. I would look
elsewhere for the problem you are experiencing.

--Michael
 
sorry ..

Michael said:
I've tested that exact code with a required field, and a compare validator,
on one text field (within a panel), and it worked fine for me. I would look
elsewhere for the problem you are experiencing.

--Michael
 
Back
Top