times when the validation of your data is so specific to your
application that you will need to write your own validation method.
The CustomValidator is designed to provide all the infrastructure
support you need. You simply point to your validation method and have
it return a Boolean value:
false. The CustomValidator control takes care of
all the rest of the work.
You’ll create a simple form that will request an even number from the user, and report the error if the number is not evenly divisible by 2. You can imagine, however, that you could perform a checksum on a credit card or ISBN or otherwise perform complex data checking.
The heart of this example is the CustomValidator control:
<asp:CustomValidator id="cvEven" controlToValidate="txtEven" Display="Static" runat="server" ClientValidationFunction="ClientValidator" OnServerValidate="ServerValidator"> Well, that's odd... </asp:CustomValidator>
The CustomValidator takes many of the usual attributes, such as an
Display. In addition, this validator has an attribute ...