自定义验证错误消息未显示在c#asp.net中

时间:2017-02-07 14:50:12

标签: c# asp.net

点击按钮后,必须检查状况。如果不是,则必须显示自定义验证消息。

但我不知道它是否正常工作?

我的代码是,

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>

0 个答案:

没有答案