日期与asp.net中的两个文本框进行比较

时间:2017-02-03 15:05:43

标签: asp.net

我有两个文本框(startdate和enddate)。 条件:startdate应该是本月的> = 21             结束日期sholud是< =下个月20 它怎么可能?

代码:

DateTime startDate1 = Convert.ToDateTime(startDateTxt.Text, System.Globalization.CultureInfo.GetCultureInfo("ta-IN").DateTimeFormat);
DateTime endDate1 = Convert.ToDateTime(endDateTxt.Text, System.Globalization.CultureInfo.GetCultureInfo("ta-IN").DateTimeFormat);
int smonth = startDate1.Month;
int day = endDate1.Day;
int emonth = endDate1.Month;


if (DateTime.Now.Month ==smonth && (emonth == DateTime.Now.Month +1 || emonth ==DateTime .Now .Month))
{
    if (endDate1 >= startDate1 && endDate1.Day <= 20)
    {
        string script = "alert(\"Possible\");";
        ScriptManager.RegisterStartupScript(this, GetType(), "ServerControlScript", script, true);
    }

}

0 个答案:

没有答案