验证结束日期应该大于开始日期?

时间:2015-02-25 12:33:52

标签: asp.net

datePicker.ascx
<asp:TextBox ID="txtDatePicker" runat="server"></asp:TextBox> 
    <asp:ImageButton runat="Server" ID="Image1" ImageUrl="~/Images/calendar.png" AlternateText="Click to show calendar" /> 
    <ajaxToolkit:CalendarExtender Format="dd/MM/yyyy" ID="CalendarExtender1" TargetControlID="txtDatePicker" runat="server" PopupButtonID="Image1" />

register.aspx
<%@ Register Src="~/Modules/datePicker.ascx" TagName ="datePicker" TagPrefix ="uc1"  %>

Start Date   <uc1:datePicker ID="datePickerSD" runat="server" >
End Date     <uc1:datePicker ID="datePickerED" runat="server" />
 <asp:CustomValidator  ID="CustomValidator1"  ControlToValidate="datePickerED"
                      ErrorMessage="End date should be greater than start date" runat="server" />

试图获得开始约会的信息......但是很困惑..

2 个答案:

答案 0 :(得分:0)

<asp:CompareValidator ID="cmpr" runat="server" ControlToCompare ="txtDate1" ControlToValidate="txtDate2" Operator="GreaterThan" Type="Date" ErrorMessage="To date should great than small data"></asp:CompareValidator>

您是否尝试过比较验证器?这可以帮到你

答案 1 :(得分:0)

解决:

<asp:CompareValidator ID="compareValidatorDate" runat="server" ControlToValidate="datePickerED$txtDatePicker" ControlToCompare ="datePickerSD$txtDatePicker" CultureInvariantValues="true" 
                                            ErrorMessage="End date should be greater than start date" Operator="GreaterThanEqual" SetFocusOnError="false" Type="String" Display="Dynamic" EnableClientScript="true" Font-Size="Small" ForeColor="Red"></asp:CompareValidator>