Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Calendar Control to show all the months of an year

Reply
Thread Tools

Calendar Control to show all the months of an year

 
 
=?Utf-8?B?U3JpZGhhcg==?=
Guest
Posts: n/a
 
      01-21-2006
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.
 
Reply With Quote
 
 
 
 
Nathan Sokalski
Guest
Posts: n/a
 
      01-22-2006
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.velocityreviews.com/forums/(E-Mail Removed)
http://www.nathansokalski.com/

"Sridhar" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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.



 
Reply With Quote
 
 
 
 
Mark Rae
Guest
Posts: n/a
 
      01-22-2006
"Sridhar" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...

> 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.


 
Reply With Quote
 
Jeff
Guest
Posts: n/a
 
      01-22-2006
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/EventCal...tCalendar.aspx

-HTH


"Mark Rae" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "Sridhar" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>
>> 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.
>



 
Reply With Quote
 
=?Utf-8?B?U3JpZGhhcg==?=
Guest
Posts: n/a
 
      01-23-2006
Thanks Mark.

"Mark Rae" wrote:

> "Sridhar" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>
> > 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.
>
>
>

 
Reply With Quote
 
Jeff
Guest
Posts: n/a
 
      01-24-2006
Happy Coding Sridhar!




"Sridhar" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Thanks Mark.
>
> "Mark Rae" wrote:
>
>> "Sridhar" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>
>> > 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.
>>
>>
>>



 
Reply With Quote
 
Mark Rae
Guest
Posts: n/a
 
      01-24-2006
"Jeff" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...

> Happy Coding Sridhar!
>
>


He'll no doubt find the 30 or so lines of code really taxing...


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calendar GadGets does not show calendar iccsi Windows 64bit 4 08-14-2011 01:52 PM
Disabling months in my calendar control Garg ASP .Net 1 03-09-2007 07:43 AM
Disabling months in my calendar control Garg ASP .Net Web Controls 0 03-09-2007 07:03 AM
Calendar control - limit possible months? =?Utf-8?B?bGFuZW0=?= ASP .Net 2 02-16-2006 02:26 PM
Showing 2 months in calendar control ericvdb ASP .Net Web Controls 2 02-23-2005 03:02 AM



Advertisments