Click here to Skip to main content
15,881,172 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I am having a Calendar control.I want to select the dates between current date and next 60 or 90 days.If i am choosing previous date than the current date then it should not be selected.Can anyone suggest me some sample code.My code looks like this:

C#
protected void Page_Load(object sender, EventArgs e)//for code behind
   {
       MyCalendar.VisibleDate = DateTime.Today;
   }
 protected void MyCalendar_PreRender(object sender, EventArgs e)
   {
       int minYear = 2013;
       int minMonth = 2;
       int minDay = 15;
       int maxYear = 2013;
       int maxMonth = 5;
       int maxDay = 30;

       if (MyCalendar.VisibleDate.Year > maxYear || (MyCalendar.VisibleDate.Year == maxYear && MyCalendar.VisibleDate.Month >= maxMonth && MyCalendar.VisibleDate.Day>=maxDay))
       {
           MyCalendar.NextMonthText = string.Empty;
       }
       else
       {
           MyCalendar.NextMonthText = ">";
       }
       if (MyCalendar.VisibleDate.Year < minYear || (MyCalendar.VisibleDate.Year == minYear && MyCalendar.VisibleDate.Month <= minMonth && MyCalendar.VisibleDate.Day>=minDay))
       {
           MyCalendar.PrevMonthText = string.Empty;
       }
       else
       {
           MyCalendar.PrevMonthText = "<";
       }

   }



ASP.NET
<asp:Calendar ID="MyCalendar"  runat="server" SelectionMode="DayWeekMonth">
Posted
Updated 14-Feb-13 23:52pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900