Click here to Skip to main content
11,637,415 members (67,036 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.8K
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 344
1 OriginalGriff 295
2 stibee 288
3 jyo.net 270
4 himanshu agarwal 209
0 OriginalGriff 9,031
1 Sergey Alexandrovich Kryukov 8,643
2 Mika Wendelius 6,959
3 F-ES Sitecore 2,388
4 Suvendu Shekhar Giri 2,320


Advertise | Privacy | Mobile
Web02 | 2.8.150728.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