A data type check
Compare the value against a fixed value
Compare the value against another
Important properties
ControlToValidate: The ID of the form field being validated.
Text: The error message.
Type: The type of value being compared.
Possible values are String, Integer, Double, Date, and Currency.
Operator: The type of comparison to perform.
Possible values are DataTypeCheck, Equal, GreaterThan, GreaterThanEqual, LessThan, LessThanEqual, and NotEqual.
ValueToCompare: The fixed value.
ControlToCompare: The ID of a control against which to compare.
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Show Data Type Check</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label
id="lblBirthDate"
Text="Birth Date:"
AssociatedControlID="txtBirthDate"
Runat="server" />
<asp:TextBox
id="txtBirthDate"
Runat="server" />
<asp:CompareValidator
id="cmpBirthDate"
Text="(Invalid Date)"
ControlToValidate="txtBirthDate"
Type="Date"
Operator="DataTypeCheck"
Runat="server" />
<br /><br />
<asp:Button
id="btnSubmit"
Text="Submit"
Runat="server" />
</div>
</form>
</body>
</html>