Click here to Skip to main content
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 15-Feb-13 0:49am
Edited 15-Feb-13 0:52am
(no name)17.7K
v2

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

  Print Answers RSS
0 OriginalGriff 7,645
1 DamithSL 5,614
2 Sergey Alexandrovich Kryukov 5,344
3 Maciej Los 4,961
4 Kornfeld Eliyahu Peter 4,539


Advertise | Privacy | Mobile
Web03 | 2.8.141223.1 | Last Updated 15 Feb 2013
Copyright © CodeProject, 1999-2014
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