如何设置当前年份asp.net中Calendar控件中显示的最大年份日期 [英] how to Set maximum years date show in Calendar control from current year asp.net
本文介绍了如何设置当前年份asp.net中Calendar控件中显示的最大年份日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,我想在日历控制中设置年度最大年数显示,例如当前年份是2014年,并且在日历中仅显示2014,2015,2016年日期的最大年份3。 plz帮我
hello everyone ,i want to set maximum number of year show from corrent year in calender control for example current year is 2014 and give maximum year 3 than show only 2014,2015,2016 years date in calender . plz help me
推荐答案
使用CalendarExtender控件的EndDate属性。要允许用户选择截至2016年的日期,您可以按如下方式设置EndDate:
CalendarExtender1.EndDate = new DateTime(DateTime.Today.Year + 2,12 ,31);
上述代码在当前年度增加2,这意味着如果当前年份是2014年,那么它将显示截至2016年的日期。
Use the EndDate property of CalendarExtender control. To allow the user to select dates upto 2016, you can set the EndDate as follows:
CalendarExtender1.EndDate = new DateTime(DateTime.Today.Year + 2, 12, 31);
The above code adds 2 to the current year, which means that if current year is 2014 then it will display dates upto 2016.
这篇关于如何设置当前年份asp.net中Calendar控件中显示的最大年份日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文