标签:
CompareValidator
属性 | 描述 |
Operator | 比较操作符,可选值DataTypeCheck、Equal、GreaterThan、GreaterThanEqul、LessThan、LessThanEqual、NotEqual |
ValueToCompare | 所比较的运算符右边的值 |
ControlToCompare | 设定与另外一个控件进行比较 |
Type | 数据类型可选String、Integer、Double、Date、Currency |
1 <form id="form1" runat="server"> 2 <div> 3 <table border="1"> 4 <tr> 5 <td class="style1">Password</td> 6 <td class="style2"> 7 <asp:TextBox ID="txtPwd" runat="server" TextMode="Password"></asp:TextBox> 8 </td> 9 </tr> 10 <tr> 11 <td class="style1">Confirm Password</td> 12 <td class="style2"> 13 <asp:TextBox ID="txtConfirmPwd" runat="server" TextMode="Password"></asp:TextBox> 14 <asp:CompareValidator ID="CompareValidator1" runat="server" 15 ControlToCompare="txtPwd" ControlToValidate="txtConfirmPwd" 16 ErrorMessage="*Password not match" ForeColor="Red"></asp:CompareValidator> 17 </td> 18 </tr> 19 </table> 20 <asp:Button ID="btnSubmit" runat="server" Text="Submit" /> 21 </div> 22 </form>
1 <form id="form1" runat="server"> 2 <div> 3 <table border="1"> 4 <tr> 5 <td class="style3">Input value </td> 6 <td class="style4"> 7 <asp:TextBox ID="txtValue" runat="server" TextMode="Number"></asp:TextBox> 8 <asp:CompareValidator ID="CompareValidator1" runat="server" 9 ControlToValidate="txtValue" ErrorMessage="* Number is not greater than 100" 10 ForeColor="Red" Operator="GreaterThan" Type="Integer" ValueToCompare="100"></asp:CompareValidator> 11 </td> 12 </tr> 13 <tr> 14 <td class="style1"> 15 <asp:Button ID="btnSubmit" runat="server" Text="Submit" /> 16 </td> 17 <td class="style2"> </td> 18 </tr> 19 </table> 20 </div> 21 </form>
标签:
原文地址:http://www.cnblogs.com/dreamtaker/p/4279783.html