ASP.NET: Calendar.SelectedDate

[VB.NET]

I have a function that is called from the end of Page_Load() that attempts to initialize the currently-selected date of several Calendar controls.

However, no matter how I try to initialize these Calendars, every time they come up with the current month (March 2004).

What's wrong with what I'm doing here?

Thanks!

         '// This code is always executed, but the calendar always displays with the current month.
         If (Not (dtCreationDate = Nothing)) Then
            '// At this point, dtCreationDate = #6/21/2001#
            sDateFormat = "yyyy/MM/dd"
            Me.calendarCreationDate.SelectedDate = dtCreationDate.ToString(sDateFormat)
         End If

I've tried it just using the DateTime variable, too:

   Me.calendarCreationDate.SelectedDate = dtCreationDate

to no avail.

What do I have to do here to initialize this stupid control?

Thanks!
brykerAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
KarunSKConnect With a Mentor Commented:
calendarCreationDate.VisibleDate = dtCreationDate
0
 
brykerAuthor Commented:

Bingo.

What's SelectedDate for, then?
0
 
KarunSKCommented:
SelectedDate is the one for getting/setting the date selected. But somebody at MS decided that for some reason you would not want the SelectedDate to be displayed as the default month; so the control displays current month by default, and forces you to override it by setting the VisibleDate property. Don't we love Microsoft? :-)

Karun.
0
 
brykerAuthor Commented:

Thanks again.  You've bailed me out 2 times in as many days.
0
All Courses

From novice to tech pro — start learning today.