Calendar.SelectedDate / VisibleDate - ASP.Net 2.0
Posted on 2006-07-04
OK, this is probably really simple, but for some reason it just does not want to work. In ASP.Net 1.1 I used to place Calendar controls on a page, then set today's date as the selected date on page load. The calendar control would then display today as the selected date.
In ASP.Net 2.0 this does not seem to work. I have the following control declared:
<asp:Calendar ID="calTimesheetDate" runat="server" SelectionMode="Day" ShowGridLines="true">
<SelectedDayStyle BackColor="Yellow" ForeColor="Red" />
On Page_Load I do the following:
calTimesheetDate.SelectedDate = DateTime.Now;
calTimesheetDate.VisibleDate = DateTime.Now;
However even though this does actually select the date of the control in memory, i.e. if I get the date from the control somewhere else on the page, it works. BUT the calendar control does not show that the date is selected.
It only displays the selected date when it is clicked on.
Why is this ???