Click here to Skip to main content
11,721,385 members (85,455 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET4.0
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:

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:Calendar ID="MyCalendar"  runat="server" SelectionMode="DayWeekMonth">
Posted 14-Feb-13 23:49pm
Edited 14-Feb-13 23:52pm
(no name)18.9K
v2

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 510
1 OriginalGriff 249
2 Mika Wendelius 170
3 F-ES Sitecore 80
4 cyycoish 70
0 Sergey Alexandrovich Kryukov 2,209
1 OriginalGriff 969
2 F-ES Sitecore 660
3 Maciej Los 609
4 Richard MacCutchan 560


Advertise | Privacy | Mobile
Web01 | 2.8.150901.1 | Last Updated 15 Feb 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100