Calendar Control to show all the months of an year

Discussion in 'ASP .Net' started by =?Utf-8?B?U3JpZGhhcg==?=, Jan 21, 2006.

  1. Hi,

    I need to display a calendar that shows all the months of an year. In
    that, I need to show different colors for certain events. I know how to
    display a calendar for a certain month but I am not sure if there is a way to
    display all the months of an year? Please let me know.

    Thanks,
    Sridhar.
     
    =?Utf-8?B?U3JpZGhhcg==?=, Jan 21, 2006
    #1
    1. Advertising

  2. The Calendar control is intended for selecting dates, so the only way to
    display all the months of the year would be to use multiple Calendar
    controls. You could do this using a control such as the Repeater, or just
    manually place multiple Calendar controls on your webform. Because the
    Calendar control is intended for selecting dates, not displaying them, I do
    not believe there is a way to make specific dates appear in different
    colors. I would suggest using some other technique to create something that
    looks similar to the Calendar control (for example, if you get creative, you
    could make a multi-column DataList and use the ItemCreated and ItemDataBound
    events to change the color, or you could just write code to generate a
    table, or you might be able to find a control on the web that you can
    download that does what you want). I don't know how much experience you have
    with what or what your ultimate goal is, so you'll have to decide for
    yourself what the best path to take is. Good Luck!
    --
    Nathan Sokalski

    http://www.nathansokalski.com/

    "Sridhar" <> wrote in message
    news:...
    > Hi,
    >
    > I need to display a calendar that shows all the months of an year. In
    > that, I need to show different colors for certain events. I know how to
    > display a calendar for a certain month but I am not sure if there is a way
    > to
    > display all the months of an year? Please let me know.
    >
    > Thanks,
    > Sridhar.
     
    Nathan Sokalski, Jan 22, 2006
    #2
    1. Advertising

  3. =?Utf-8?B?U3JpZGhhcg==?=

    Mark Rae Guest

    "Sridhar" <> wrote in message
    news:...

    > I need to display a calendar that shows all the months of an year. In
    > that, I need to show different colors for certain events. I know how to
    > display a calendar for a certain month but I am not sure if there is a way
    > to
    > display all the months of an year? Please let me know.


    This is easy enough using the calendar control (actually, 12 calendar
    controls), maybe arranged in a convenient 3 x 4 grid.

    1) In the page's ViewState, store the first day of the first calendar

    2) Create 12 calendar controls in the HTML portion of your ASPX page - call
    them something like 'cal0', 'cal1', 'cal2' etc
    <asp:Calendar ID="cal0" OnDayRender="DayRender" runat=server
    ShowNextPrevMonth="false" OtherMonthDayStyle-ForeColor="DarkGray"><DayStyle
    Font-Size="XX-Small" /><DayHeaderStyle Font-Size="XX-Small"
    /></asp:Calendar>

    3) Set the date of the first calendar to whatever you want your starting
    date to be, maybe the current date, e.g.
    cal0.TodaysDate = DateTime.Now;
    cal0.VisibleDate = DateTime.Now;

    4) Increment the starting date of each subsequent calendar e.g.
    cal1.VisibleDate = cal0.VisibleDate.AddMonths(1);
    cal2.VisibleDate = cal1.VisibleDate.AddMonths(1);
    etc

    5) In your code-behind, retrieve all the events which fall between the first
    day of the first calendar and 365 days in advance of that date, and store
    them in a Hashtable

    6) Create a method called DayRender, as follows:

    public void DayRender(object source, DayRenderEventArgs e)
    {
    if (htblDates.ContainsKey(e.Day.Date.ToString("dd MMM yyyy")) &&
    !e.Day.IsOtherMonth)
    {
    e.Cell.Font.Bold = true;
    }
    }

    There are loads of other things you can do - you could change the day's
    background colour, add text underneath it etc, but the above should be
    enough to get you started.
     
    Mark Rae, Jan 22, 2006
    #3
  4. =?Utf-8?B?U3JpZGhhcg==?=

    Jeff Guest

    That's all fine and good if you have more time than money. If budget is a
    concern (i.e., one values his/her time and can place a dollar value on it),
    then here's a great control that works well for a reasonable price:

    http://www.quickwebsoft.com/EventCalendar/EventCalendar.aspx

    -HTH


    "Mark Rae" <> wrote in message
    news:...
    > "Sridhar" <> wrote in message
    > news:...
    >
    >> I need to display a calendar that shows all the months of an year. In
    >> that, I need to show different colors for certain events. I know how to
    >> display a calendar for a certain month but I am not sure if there is a
    >> way to
    >> display all the months of an year? Please let me know.

    >
    > This is easy enough using the calendar control (actually, 12 calendar
    > controls), maybe arranged in a convenient 3 x 4 grid.
    >
    > 1) In the page's ViewState, store the first day of the first calendar
    >
    > 2) Create 12 calendar controls in the HTML portion of your ASPX page -
    > call them something like 'cal0', 'cal1', 'cal2' etc
    > <asp:Calendar ID="cal0" OnDayRender="DayRender" runat=server
    > ShowNextPrevMonth="false"
    > OtherMonthDayStyle-ForeColor="DarkGray"><DayStyle Font-Size="XX-Small"
    > /><DayHeaderStyle Font-Size="XX-Small" /></asp:Calendar>
    >
    > 3) Set the date of the first calendar to whatever you want your starting
    > date to be, maybe the current date, e.g.
    > cal0.TodaysDate = DateTime.Now;
    > cal0.VisibleDate = DateTime.Now;
    >
    > 4) Increment the starting date of each subsequent calendar e.g.
    > cal1.VisibleDate = cal0.VisibleDate.AddMonths(1);
    > cal2.VisibleDate = cal1.VisibleDate.AddMonths(1);
    > etc
    >
    > 5) In your code-behind, retrieve all the events which fall between the
    > first day of the first calendar and 365 days in advance of that date, and
    > store them in a Hashtable
    >
    > 6) Create a method called DayRender, as follows:
    >
    > public void DayRender(object source, DayRenderEventArgs e)
    > {
    > if (htblDates.ContainsKey(e.Day.Date.ToString("dd MMM yyyy")) &&
    > !e.Day.IsOtherMonth)
    > {
    > e.Cell.Font.Bold = true;
    > }
    > }
    >
    > There are loads of other things you can do - you could change the day's
    > background colour, add text underneath it etc, but the above should be
    > enough to get you started.
    >
     
    Jeff, Jan 22, 2006
    #4
  5. Thanks Mark.

    "Mark Rae" wrote:

    > "Sridhar" <> wrote in message
    > news:...
    >
    > > I need to display a calendar that shows all the months of an year. In
    > > that, I need to show different colors for certain events. I know how to
    > > display a calendar for a certain month but I am not sure if there is a way
    > > to
    > > display all the months of an year? Please let me know.

    >
    > This is easy enough using the calendar control (actually, 12 calendar
    > controls), maybe arranged in a convenient 3 x 4 grid.
    >
    > 1) In the page's ViewState, store the first day of the first calendar
    >
    > 2) Create 12 calendar controls in the HTML portion of your ASPX page - call
    > them something like 'cal0', 'cal1', 'cal2' etc
    > <asp:Calendar ID="cal0" OnDayRender="DayRender" runat=server
    > ShowNextPrevMonth="false" OtherMonthDayStyle-ForeColor="DarkGray"><DayStyle
    > Font-Size="XX-Small" /><DayHeaderStyle Font-Size="XX-Small"
    > /></asp:Calendar>
    >
    > 3) Set the date of the first calendar to whatever you want your starting
    > date to be, maybe the current date, e.g.
    > cal0.TodaysDate = DateTime.Now;
    > cal0.VisibleDate = DateTime.Now;
    >
    > 4) Increment the starting date of each subsequent calendar e.g.
    > cal1.VisibleDate = cal0.VisibleDate.AddMonths(1);
    > cal2.VisibleDate = cal1.VisibleDate.AddMonths(1);
    > etc
    >
    > 5) In your code-behind, retrieve all the events which fall between the first
    > day of the first calendar and 365 days in advance of that date, and store
    > them in a Hashtable
    >
    > 6) Create a method called DayRender, as follows:
    >
    > public void DayRender(object source, DayRenderEventArgs e)
    > {
    > if (htblDates.ContainsKey(e.Day.Date.ToString("dd MMM yyyy")) &&
    > !e.Day.IsOtherMonth)
    > {
    > e.Cell.Font.Bold = true;
    > }
    > }
    >
    > There are loads of other things you can do - you could change the day's
    > background colour, add text underneath it etc, but the above should be
    > enough to get you started.
    >
    >
    >
     
    =?Utf-8?B?U3JpZGhhcg==?=, Jan 23, 2006
    #5
  6. =?Utf-8?B?U3JpZGhhcg==?=

    Jeff Guest

    Happy Coding Sridhar!

    :)


    "Sridhar" <> wrote in message
    news:...
    > Thanks Mark.
    >
    > "Mark Rae" wrote:
    >
    >> "Sridhar" <> wrote in message
    >> news:...
    >>
    >> > I need to display a calendar that shows all the months of an year. In
    >> > that, I need to show different colors for certain events. I know how to
    >> > display a calendar for a certain month but I am not sure if there is a
    >> > way
    >> > to
    >> > display all the months of an year? Please let me know.

    >>
    >> This is easy enough using the calendar control (actually, 12 calendar
    >> controls), maybe arranged in a convenient 3 x 4 grid.
    >>
    >> 1) In the page's ViewState, store the first day of the first calendar
    >>
    >> 2) Create 12 calendar controls in the HTML portion of your ASPX page -
    >> call
    >> them something like 'cal0', 'cal1', 'cal2' etc
    >> <asp:Calendar ID="cal0" OnDayRender="DayRender" runat=server
    >> ShowNextPrevMonth="false"
    >> OtherMonthDayStyle-ForeColor="DarkGray"><DayStyle
    >> Font-Size="XX-Small" /><DayHeaderStyle Font-Size="XX-Small"
    >> /></asp:Calendar>
    >>
    >> 3) Set the date of the first calendar to whatever you want your starting
    >> date to be, maybe the current date, e.g.
    >> cal0.TodaysDate = DateTime.Now;
    >> cal0.VisibleDate = DateTime.Now;
    >>
    >> 4) Increment the starting date of each subsequent calendar e.g.
    >> cal1.VisibleDate = cal0.VisibleDate.AddMonths(1);
    >> cal2.VisibleDate = cal1.VisibleDate.AddMonths(1);
    >> etc
    >>
    >> 5) In your code-behind, retrieve all the events which fall between the
    >> first
    >> day of the first calendar and 365 days in advance of that date, and store
    >> them in a Hashtable
    >>
    >> 6) Create a method called DayRender, as follows:
    >>
    >> public void DayRender(object source, DayRenderEventArgs e)
    >> {
    >> if (htblDates.ContainsKey(e.Day.Date.ToString("dd MMM yyyy")) &&
    >> !e.Day.IsOtherMonth)
    >> {
    >> e.Cell.Font.Bold = true;
    >> }
    >> }
    >>
    >> There are loads of other things you can do - you could change the day's
    >> background colour, add text underneath it etc, but the above should be
    >> enough to get you started.
    >>
    >>
    >>
     
    Jeff, Jan 24, 2006
    #6
  7. =?Utf-8?B?U3JpZGhhcg==?=

    Mark Rae Guest

    "Jeff" <> wrote in message
    news:...

    > Happy Coding Sridhar!
    >
    > :)


    He'll no doubt find the 30 or so lines of code really taxing...
     
    Mark Rae, Jan 24, 2006
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?bGFuZW0=?=

    Calendar control - limit possible months?

    =?Utf-8?B?bGFuZW0=?=, Feb 16, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    616
  2. Otuatail

    Week of year to full Year

    Otuatail, Dec 8, 2003, in forum: HTML
    Replies:
    4
    Views:
    971
    Toby A Inkster
    Dec 8, 2003
  3. Garg
    Replies:
    1
    Views:
    445
    Muhammad Naveed Yaseen
    Mar 9, 2007
  4. ericvdb

    Showing 2 months in calendar control

    ericvdb, Feb 22, 2005, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    144
    MasterGaurav
    Feb 23, 2005
  5. Garg

    Disabling months in my calendar control

    Garg, Mar 9, 2007, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    129
Loading...

Share This Page