Solved

ASP.NET:  Calendar.SelectedDate

Posted on 2004-03-31
4
743 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

Suggested Solutions

A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

759 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