How to limit year in ajax calendar extender

2019-07-04 06:41发布

问题:

I have a Calendar Extender.

I want to show only current year in calendar.

User can not select 2010 as current year is 2011.

So how to do this ?

回答1:

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.

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


回答2:

Use StartDate property of your extender. For example:

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

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