ValidationDataType Enumeration
Specifies the validation data types used by the CompareValidator and RangeValidator controls.
Assembly: System.Web (in System.Web.dll)
| Member name | Description | |
|---|---|---|
| String | A string data type. The value is treated as a System.String. | |
| Integer | A 32-bit signed integer data type. The value is treated as a System.Int32. | |
| Double | A double precision floating point number data type. The value is treated as a System.Double. | |
| Date | A date data type. Only numeric dates are allowed. The time portion cannot be specified. | |
| Currency | A monetary data type. The value is treated as a System.Decimal. However, currency and grouping symbols are still allowed. |
The ValidationDataType enumeration represents the different data types that the CompareValidator and RangeValidator controls can validate. When you specify a data type for validation control and the input control being validated passes validation, the value of the input control can be parsed to the specified data type.
<%@ Page Language="JScript" AutoEventWireup="True" %> <!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> <title>CompareValidator Example</title> <script runat="server"> function Button_Click(sender, e : EventArgs) { if (Page.IsValid) { lblOutput.Text = "Result: Valid!"; } else { lblOutput.Text = "Result: Not valid!"; } } function Operator_Index_Changed(sender, e : EventArgs) { Compare1.Operator = ValidationCompareOperator(ListOperator.SelectedIndex); Compare1.Validate(); } function Type_Index_Changed(sender, e : EventArgs) { Compare1.Type = ValidationDataType(ListType.SelectedIndex); Compare1.Validate(); } </script> </head> <body> <form id="form1" runat="server"> <h3>CompareValidator Example</h3> <br /> Enter a value in each textbox. Select a comparison operator<br /> and data type. Click "Validate" to compare values. <table style="background-color:#eeeeee; padding:10"> <tr valign="top"> <td> <h5>String 1:</h5> <asp:TextBox id="TextBox1" runat="server"/> </td> <td> <h5>Comparison Operator:</h5> <asp:ListBox id="ListOperator" OnSelectedIndexChanged="Operator_Index_Changed" runat="server"> <asp:ListItem Selected="true" Value="Equal">Equal</asp:ListItem> <asp:ListItem Value="NotEqual">NotEqual</asp:ListItem> <asp:ListItem Value="GreaterThan">GreaterThan</asp:ListItem> <asp:ListItem Value="GreaterThanEqual">GreaterThanEqual</asp:ListItem> <asp:ListItem Value="LessThan">LessThan</asp:ListItem> <asp:ListItem Value="LessThanEqual">LessThanEqual</asp:ListItem> <asp:ListItem Value="DataTypeCheck">DataTypeCheck</asp:ListItem> </asp:ListBox> </td> <td> <h5>String 2:</h5> <asp:TextBox id="TextBox2" runat="server"/> <br /> <asp:Button id="Button1" Text="Validate" OnClick="Button_Click" runat="server"/> </td> </tr> <tr> <td colspan="3" align="center"> <h5>Data Type:</h5> <asp:ListBox id="ListType" OnSelectedIndexChanged="Type_Index_Changed" runat="server"> <asp:ListItem Selected="true" Value="String" >String</asp:ListItem> <asp:ListItem Value="Integer" >Integer</asp:ListItem> <asp:ListItem Value="Double" >Double</asp:ListItem> <asp:ListItem Value="Date" >Date</asp:ListItem> <asp:ListItem Value="Currency" >Currency</asp:ListItem> </asp:ListBox> </td> </tr> </table> <asp:CompareValidator id="Compare1" ControlToValidate="TextBox1" ControlToCompare="TextBox2" EnableClientScript="False" Type="String" runat="server"/> <br /> <asp:Label id="lblOutput" Font-Name="verdana" Font-Size="10pt" runat="server"/> </form> </body> </html>
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.