Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
161 views
in Technique[技术] by (71.8m points)

asp.net - Validate end date should be greater than start date?

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" />
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
<asp:CompareValidator ID="cmpr" runat="server" ControlToCompare ="txtDate1" ControlToValidate="txtDate2" Operator="GreaterThan" Type="Date" ErrorMessage="To date should great than small data"></asp:CompareValidator>

Have you tried compare validator ? This can help you


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...