如何在ajax控件工具包日历扩展器中禁用5天前的过去日期

时间:2017-07-20 00:24:46

标签: c# asp.net

//这是我的代码背后

TextBox dt = (TextBox)f.Controls[0].FindControl("TextBox1");
                dt.Text = string.Format("{0:MMM dd, yyyy}", DateTime.Now);
                CalendarExtender c1 = (CalendarExtender)f.Controls[0].FindControl("CalenderExtender1");

This code decide disable date

                c1.StartDate = new DateTime(DateTime.Today.Year, 1, 1);  //to dissable past Date but i want 5 days back ??????????
                c1.EndDate = new DateTime(DateTime.Today.Year, DateTime.Today.Month, DateTime.Today.Day);//to dissable future  Date

任何人都可以帮助我?

1 个答案:

答案 0 :(得分:1)

从我现有的代码中我想在这一行

 c1.StartDate = new DateTime(DateTime.Today.Year, 1, 1);

尝试将其更改为endDate,但添加-5

 c1.StartDate = new DateTime(DateTime.Today.Year,DateTime.Today.Month,DateTime.Today.Day -5);

不是100%肯定导致我还没有测试它