c# – asp CompareValidator validating after postback – Education Career Blog

Is there any reason an asp CompareValidator validates after postback. ie everything runs when i click the button, and the error of the validator shows on the screen after postback.
i have a compare validator on 2 dates (datefrom and dateto). if the dates are in gregorian format the validator works fine, but if the dates are in hijri format, the above scenario takes place.
this is my validator:

  <asp:ValidCompareValidator ID="vcvDate" runat="server" ControlToValidate="cDateTo" ControlToCompare="cDateFrom" Operator="GreaterThanEqual" Type="Date" CultureInvariantValues="true" />

,

The control can’t handle doing non-Gregorian comparisons on the client. You’ll have to do server-side validation (or use a custom validator).

From the BaseCompareValidator.Type property page on MSDN:

When the Type property is set to Date and the current calendar type is non-Gregorian, the validator performs server-side validation only. The validator client script supports only Gregorian calendars.

Leave a Comment