OnDayRender not changing background color until month is changed.

2 posts, 0 answers
  1. Sean
    Sean avatar
    4 posts
    Member since:
    Oct 2013

    Posted 26 May 2016 Link to this post

    I am changing the background color of a date ( that is being provided from the database ) by using the Calendar OnDayRender.  The problem is that when the page initially loads the background color is not present.  But if I change the month, then go back to the previous month, the background color appears.



    <telerik:RadDatePicker AutoPostBack="true" OnSelectedDateChanged="rdpEnd_SelectedDateChanged" ID="rdpEnd" ToolTip="" class="form-control" Style="width: 100%;" Height="30px" aria-describedby="ptoEndDate" runat="server">
    <DatePopupButton ToolTip="" />
    <Calendar runat="server" ShowRowHeaders="false" OnDayRender="CustomizeDay">



    protected void CustomizeDay(object sender, Telerik.Web.UI.Calendar.DayRenderEventArgs e)
      DateTime CurrentDate = e.Day.Date;
      using (DataClassesDataContext db = new DataClassesDataContext())
        if(db.Calendars.Where(x => x.date.Value.Date == e.Day.Date).Any())
           TableCell currentCell = e.Cell;
           currentCell.Style["background-color"] = "#000000";


  2. Viktor Tachev
    Viktor Tachev avatar
    1788 posts

    Posted 31 May 2016 Link to this post

    Hi Sean,

    In order to customize some dates in the DatePicker you need to handle the DayRender events on the server and on the client. Check out the following code-library that illustrates similar scenario.

    Viktor Tachev
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Back to Top