Pat James.com

Image
RSS

Navigation





Quick Search
»
Advanced Search »

I had a lot of trouble getting my CustomValidator events to fire on a radiobuttonlist until I figured out that they needed to have ValidateEmptyText="true" in order to be invoked when nothing was selected.

Here's my complete CustomValidator:

<asp:CustomValidator ID="custvalBirthCenters" runat="server" ControlToValidate="rbBirthCenters"
    ValidationGroup="DoulaProfile" OnServerValidate="ValidateBirthCenters"
    ErrorMessage="Please indicate whether you attend births at birth centers."
    Display="Dynamic" Text="*" CssClass="validation" Enabled="true" ValidateEmptyText="true" ></asp:CustomValidator>

Other things to check if it isn't firing:
  • Does the ValidationGroup value match in all 3 places: the submit button, the validator control, and the control to validate?
  • Does the submit button have CausesValidation=true

This site built on ScrewTurn Wiki version 3.0.2.509...a cool open source .NET wiki

Don't forget to tell all your pregnant friends about DoulaMatch and the BirthWatch Facebook app