views:

90

answers:

2

I have a calendar control on a asp .net webform. In the Pag_Load event I have

this.CalendarReportDay.SelectedDate = DateTime.Now;

Which sets the Calendar's Selected Date but todays date is not highlighted on the calendar.

Does anyone know how to get todays date to be selected?

A: 

the .SelectedDate will set the calendar's date, but that does not mean it will hightlight it.

have a look at:

http://www.devtoolshed.com/content/how-highlight-day-aspnet-calendar-control-selecteddate-property

del.ave
A: 

You have to set

this.CalendarReportDay.SelectedDate = DateTime.Now.Date;

The Date property at the end is important, otherwise the time component of DateTime.Now will prevent the selection. Then it gets the applied SelectedDayStyle, f.e.

<asp:Calendar ID="CalendarReportDay" runat="server">
   <SelectedDayStyle Font-Size="X-Large" />
</asp:Calendar>
Tim Schmelter