Manual Validate call always returns IsValid=true

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
 
M

Michael

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
 
J

Jon Davis

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
 
J

Jon Davis

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top