Solved

ASP.NET:  Calendar.SelectedDate

Posted on 2004-03-31
4
731 Views
Last Modified: 2012-06-21
[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!
0
Comment
Question by:bryker
  • 2
  • 2
4 Comments
 
LVL 6

Accepted Solution

by:
KarunSK earned 250 total points
ID: 10729655
calendarCreationDate.VisibleDate = dtCreationDate
0
 

Author Comment

by:bryker
ID: 10732569

Bingo.

What's SelectedDate for, then?
0
 
LVL 6

Expert Comment

by:KarunSK
ID: 10733974
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
 

Author Comment

by:bryker
ID: 10734176

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

Featured Post

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question