RadCalendar for ASP.NET AJAX

RadControls for ASP.NET AJAX

The OnDayRender client-side event handler is called for every calendar day cell when the calendar is rendered as a result of client-side navigation. This event mimics the server-side DayRender event, giving final control over the output of a specific calendar day cell. This event can be used to apply changes to the calendar cells when the user navigates that are identical to the server-side event handler applied to the cells in the initial view.

Note

The OnDayRender event is supported by: RadCalendar.

Two parameters are passed to the event handler:

  • sender is the calendar control.

  • eventArgs has the following properties:

    • get_renderDay() returns the client-side RenderDay object that represents the day being rendered. This value is null if the cell represents a value outside the range specified by RangeMinDate and RangeMaxDate.

    • get_date() returns the triplet for the date the cell represents.

    • get_cell() returns object for the cell being rendered.

The following example uses the OnDayRender event to change the text for the non-current month and for dates that fall outside the selectable range. It also changes the background color on weekend days:

CopyASPX
<script type="text/javascript">
    function RenderADay(sender, eventArgs) {
        var cell = eventArgs.get_cell();
        var day = eventArgs.get_renderDay();
        if (day) {
            var view = day.RadCalendarView;
            if (eventArgs.get_date()[1] != view._MonthStartDate[1]) {
                cell.innerText = "(" + cell.innerText + ")";
            }

            if (day.get_isWeekend())
                cell.style.backgroundColor = "#efefef";
        }
        else
            cell.innerText = "";
    }
</script>
<telerik:RadCalendar ID="RadCalendar1" runat="server">
    <ClientEvents OnDayRender="RenderADay" />
</telerik:RadCalendar>

See Also

Other Resources