Get the month and year of Calendar that current displaying

G

Guest

How can I get the month and year a calendar control current displaying?

My problem is I want to load a list of event to a calendar so that it
display difference style if there a event for a day.

My initial idea is load all events from database and store it in a
DataTable. In the DayRender event, loop thr the DataTable and see if it equal
to e.Day and alter the style if that is.

However when the event table is large, it hurt performance. So how get I
know what month and year the calendar control is current displaying, thus I
can only load the events of specified month and year only?

Thanks in advance.

Jason
 
R

Rob Meade

...
However when the event table is large, it hurt performance. So how get I
know what month and year the calendar control is current displaying, thus
I
can only load the events of specified month and year only?

Thanks in advance.

Hi Jason,

I'm not overly familiar with the calendar control, however, from memory,
cant you access the "selecteditem" - if so, you should be able to get the
date from that - thus breaking it up and getting the month and year...

Again not overly familiar with it - but that should work I think...

Regards

Rob
 
J

Jason Chan

It doesn't work, i have a test.aspx with a Label and a Calendar, with
following code

protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = Calendar1.VisibleDate.ToString();
}

The Label1 show "1/1/0001 0:00:00" when the page first loaded, currently
month/year is Nov, 2005
When I click the nextMonth link, Calendar current displaying Dec, 2005,
however the Label1 show "1/1/0001 0:00:00",
When I click the nextMonth again, The Calendar now is Jan, 2006, but the
Label is "1/12/2005 0:00:00"
Then I click prevMonth, The Calendar back to Dec 2005, the Label shows
"1/1/2006 0:00:00"

It seem the VisibleDate always keep the previous value, and initial
undefined when the page first load.
Anyone can explain the behavior?

Or how you guys implements a event calendar?

Thanks in advance



"Brock Allen" <[email protected]>
???????:[email protected]...
Calendar.VisibleDate
 
J

Jason Chan

This doesn;t work, since when the page first loaded, no date is selected.


However when the event table is large, it hurt performance. So how get I
know what month and year the calendar control is current displaying, thus
I
can only load the events of specified month and year only?

Thanks in advance.

Hi Jason,

I'm not overly familiar with the calendar control, however, from memory,
cant you access the "selecteditem" - if so, you should be able to get the
date from that - thus breaking it up and getting the month and year...

Again not overly familiar with it - but that should work I think...

Regards

Rob
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top