I recently came across a frustrating scenario in which my validator controls seemed to be set up properly but would not fire when expected. Here’s the background:
The validators and the controls that they were meant to validate were children of a user control that allowed the user to edit billing address information for a credit card payment processing page. In the markup for the ASPX page, this user control had its Visible attribute set to false because the billing address edit form was not part of the initial view of the page.
When the user requested the billing address edit form, code in the page load event would override the visibility of the user control to make it visible.
It appears that setting Visible to true during page load is too late for the controls to be included in the page validation. This seems reasonable now given the timing of the validation operations in the page lifecycle, but it was not obvious at first and caused me a significant amount of frustration.
The fix was to have the user control’s Visible attribute set to true in the markup and then override this setting to false as needed in code.
I hope that by posting this, I might save someone else from going through the same struggle as I did.