Solved

ASP.NET:  Calendar.SelectedDate

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
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, f…

863 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

26 Experts available now in Live!

Get 1:1 Help Now