点击按钮后,必须检查状况。如果不是,则必须显示自定义验证消息。
但我不知道它是否正常工作?
我的代码是,
aspx.cs
protected void validateendtxt(object sender, ServerValidateEventArgs e)
{
DateTime startDate1 = Convert.ToDateTime(startDateTxt.Text, System.Globalization.CultureInfo.GetCultureInfo("ta-IN").DateTimeFormat);
string str = startDate1.ToString("dd/MM/yyyy");
DateTime startDate2 = Convert.ToDateTime(str, System.Globalization.CultureInfo.GetCultureInfo("ta-IN").DateTimeFormat);
DateTime endDate1 = Convert.ToDateTime(endDateTxt.Text, System.Globalization.CultureInfo.GetCultureInfo("ta-IN").DateTimeFormat);
string str1 = endDate1.ToString("dd/MM/yyyy");
DateTime endDate2 = Convert.ToDateTime(str1, System.Globalization.CultureInfo.GetCultureInfo("ta-IN").DateTimeFormat);
if (startDate2 >= endDate2)
{
e.IsValid = false;
}
else
{
e.IsValid = true;
}
}
ASPX
<asp:CustomValidator ID ="cusvalid" runat ="server" ErrorMessage ="It Should be greater" Display ="Dynamic" OnServerValidate="validateendtxt">*</asp:CustomValidator>