如何验证 RadDateTimePicker 中选定的日期时间值是否大于使用服务器端验证的 asp.net中的当前系统日期时间值。
<telerik:RadDateTimePicker runat="server" ID="orderDate" >
<Calendar ID="Calendar1" runat="server" EnableKeyboardNavigation="true">
</Calendar>
</telerik:RadDateTimePicker>
答案 0 :(得分:1)
要验证它,您需要使用CompareValidator或CustomValidator。
请使用以下日期时间选择器标记:
<telerik:RadDateTimePicker runat="server" ID="orderDate">
<Calendar ID="Calendar1" runat="server" EnableKeyboardNavigation="true">
</Calendar>
</telerik:RadDateTimePicker>
<asp:CustomValidator ID="cvOrderDate" runat="server" ControlToValidate="orderDate" ValidationGroup="vgSubmit" ErrorMessage="Please use correct date" OnServerValidate="cvOrderDate_ServerValidate"></asp:CustomValidator>
代码背后:
protected void cvOrderDate_ServerValidate(object source, ServerValidateEventArgs args)
{
args.IsValid = orderDate.SelectedDate.Value > DateTime.Now;
}
此处还有一个RadDateTimePicker验证演示http://demos.telerik.com/aspnet-ajax/calendar/examples/datetimepicker/validation/defaultcs.aspx