Calendar control...

  • Thread starter Thread starter RAB
  • Start date Start date
R

RAB

I want to make my calendar control only be able to change the month
for the current year. ie I want to be able to scroll to Feb 07, Jan
07 but not to Dec 06. Any ideas of how to set this functionality up?

Thanks,
RABMissouri2007
 
Hello RAB,

One way to do this would be to handle the VisibleMonthChanged event. In the
event handler you could have code which looked like this:
=-=-=-=-=-=-=-
protected void Calendar1_VisibleMonthChanged(object sender,
MonthChangedEventArgs e)
{
DateTime dt = new DateTime(DateTime.Now.Year, 2, 1);

// check to see if the newdate is before feb, if it is get rid of
the prevmonthtext
if (e.NewDate < dt)
{
Calendar1.PrevMonthText = "";
}
// if the new date is greater than jan, set the text
else
{
Calendar1.PrevMonthText = "<";
}
}
 
Back
Top