Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

calendar control question

Status
Not open for further replies.

drew10

Programmer
Feb 26, 2002
123
US
I have a page that displays a calendar control. I need to know what month is currently displayed on the calendar even if no date is selected. Thus I cannot use: calendar1.selectedDate. Any help is greatly appreciated!
-drew10
 
Get it: calDate.VisibleDate.Month.ToString();
Set it: calDate.VisibleDate = DateTime.Today;

(ignore the ';' if you are using VB.net)

Remember that to set the visible date, it must be a full date, and not just a year. If you don't have a specific date, then get the month and append "/1/2002", or whatever year you are using.

Hope this helps. ________________________________________
Michael C Flanakin
Indigo Web Systems
michael.flanakin@indigows.com
 
If I am not mistaken a date is always selected. If no one has selected anything yet then it's the default date or today's date if the default isn't specified. That'l do donkey, that'l do
[bravo] Mark
 
month(calendar1.selectedDate)

and I have this class that gives month name from number if you need it. Someone here at work wrote it for me. He left, but I got to keep his code. lemme know if you need it.

[rofl]

paul
penny1.gif
penny1.gif
 
Zarcom,
the default date is today, correct, but drew10 was asking about the current month. If the user selects previous/next month, then the SelectedDate property will not be the current month.

link9,
I believe that you can get the month without calling a function - it's actually a property of the SelectedDate property:
calDate.SelectedDate.Month ________________________________________
Michael C Flanakin
Indigo Web Systems
michael.flanakin@indigows.com
 
My problem entailed highlighting certain dates throughout the year on which events are occurring. I found that you can set a multidimensional array such as eventDates(12,31) and fill the array with event names like so:

eventDates(12,25) = "Christmas"

You can then use the calendar.DayRender to check if each day rendered is an event day. If it is, you can highlight the cell being rendered accordingly.

Thanks for all of the suggestions!
 
If that's what you want, then why bother figuring out what month it is? All you want is the date, right? So...
Code:
sub calendar_dayrender(obj as object, e as dayrendereventargs)
   for each dateItem in eventDates
      if e.day.date = dateItem then
         e.cell.style("BACKGROUND-COLOR") = 'color
         e.cell.style("FONT-BOLD") = true
         exit for
      end if
   next    
end sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top