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?
SelectedDatewill set the calendar’s date, but that does not mean it will highlight it.One issue is that
DateTime.Nowincludes the time whereas the calendar needs ONLY the date to work as expected, so you can useDateTime.Todayinstead, e.g.To show the date (i.e. to get the calendar to display the correct month and year needed to show the selected date) use
VisibleDate, e.g.For more details, have a look at:
http://www.devtoolshed.com/content/how-highlight-day-aspnet-calendar-control-selecteddate-property