Set Calendar SelectedDate not displaying RRS feed

  • Question

  • I have a calendar

    <asp:Calendar ID="cal" runat="server" SelectedDayStyle-BackColor="Red" TodayDayStyle-BackColor="Yellow"></asp:Calendar>

    when set the selcted date at page_load, it doesn't display the selected date; the backcolor changes only if clicks on the day

    cal.SelectedDate = DateTime.Now.Subtract(System.TimeSpan.FromDays(2));

    from this post the workaround is set the "TodaysDate"

    is it a known issue?

    Monday, May 6, 2013 1:27 AM


  • Try this:

    var d = DateTime.Today.AddDays(-2);
    cal.VisibleDate = d;

    • Marked as answer by xhuan8 Monday, May 6, 2013 11:57 AM
    Monday, May 6, 2013 6:52 AM