如何限制ajax日历扩展器中的年份

时间:2021-11-24 03:17:43

I have a Calendar Extender.

我有一个Calendar Extender。

I want to show only current year in calendar.

我想在日历中仅显示当前年份。

User can not select 2010 as current year is 2011.

用户无法选择2010年,因为当前年份是2011年。

So how to do this ?

那怎么办呢?

2 个解决方案

#1


3  

Use the StartDate and EndDate properties to set a range of acceptable dates that you want to allow the user to select - you can set this in the markup as per krolik's answer, or in the code-behind so you can set it to the current year e.g.

使用StartDate和EndDate属性设置允许用户选择的可接受日期范围 - 您可以根据krolik的答案在代码中设置此项,或者在代码隐藏中设置此项,以便将其设置为当前年份例如

CalendarExtender.StartDate = new DateTime(DateTime.Today.Year,1,1);
CalendarExtender.EndDate = new DateTime(DateTime.Today.Year,12,31);

#2


1  

Use StartDate property of your extender. For example:

使用扩展程序的StartDate属性。例如:

<ajax:CalendarExtender ID="Calendar" StartDate="1/1/2011" runat="server" ... /> 

StartDate - Indicates start date for range that available for selection.

StartDate - 表示可供选择的范围的开始日期。

#1


3  

Use the StartDate and EndDate properties to set a range of acceptable dates that you want to allow the user to select - you can set this in the markup as per krolik's answer, or in the code-behind so you can set it to the current year e.g.

使用StartDate和EndDate属性设置允许用户选择的可接受日期范围 - 您可以根据krolik的答案在代码中设置此项,或者在代码隐藏中设置此项,以便将其设置为当前年份例如

CalendarExtender.StartDate = new DateTime(DateTime.Today.Year,1,1);
CalendarExtender.EndDate = new DateTime(DateTime.Today.Year,12,31);

#2


1  

Use StartDate property of your extender. For example:

使用扩展程序的StartDate属性。例如:

<ajax:CalendarExtender ID="Calendar" StartDate="1/1/2011" runat="server" ... /> 

StartDate - Indicates start date for range that available for selection.

StartDate - 表示可供选择的范围的开始日期。