错误是:
字符串未被识别为有效的日期时间。
自定义验证器的功能:
protected void chkdate1(object sender, ServerValidateEventArgs e)
{
IFormatProvider theCultureInfo = new System.Globalization.CultureInfo("en-GB", true);
DateTime from = DateTime.ParseExact(txt_from_date.Text, "MM/dd/yyyy HH:mm:ss", theCultureInfo);
DateTime to = DateTime.ParseExact(txt_to_date.Text, "MM/dd/yyyy HH:mm:ss", theCultureInfo);
}
自定义验证是:
<asp:CustomValidator ID="scdt1" runat="server" OnServerValidate="chkdate1" ErrorMessage="To date not less than From date">