我有两个DropDownLists
填充了Year-Dates
,我希望在第二个ddls值小于第一个ddls值的情况下显示错误消息。
这是我到目前为止使用的代码,它不起作用:
<asp:CompareValidator
ID="cvEndYear2" Operator="GreaterThan" runat="server" CssClass="text-danger"
ValidationGroup="Save" ControlToValidate="ddlEndYear" Display="Dynamic"
ValueToCompare="ddlStartYear" ErrorMessage="Greater Than" SetFocusOnError="true">
</asp:CompareValidator>
答案 0 :(得分:2)
答案 1 :(得分:2)
您必须指定ControlToCompare
和Operator
:
<asp:CompareValidator
ID="cvEndYear2" Operator="GreaterThan" runat="server" CssClass="text-danger"
ValidationGroup="Save"
ControlToValidate="ddlEndYear" Display="Dynamic"
ControlToCompare="ddlStartYear"
Operator="GreaterThanEqual"
Type="Integer"
ErrorMessage="The end year must be greater/equal the start year" SetFocusOnError="true">
</asp:CompareValidator>