Solved

ASP.NET:  Calendar.SelectedDate

Posted on 2004-03-31
4
701 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

705 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now