Skip to main content

ASPxScheduler.HtmlTimeCellPrepared Event

Occurs when the HTML code representing the time cell is prepared for display.

Namespace: DevExpress.Web.ASPxScheduler

Assembly: DevExpress.Web.ASPxScheduler.v24.1.dll

NuGet Package: DevExpress.Web.Scheduler

Declaration

public event ASPxSchedulerTimeCellPreparedEventHandler HtmlTimeCellPrepared

Event Data

The HtmlTimeCellPrepared event's data class is ASPxSchedulerTimeCellPreparedEventArgs. The following properties provide information specific to this event:

Property Description
Cell Provides access to the HTML table cell which represents the current time cell of the Scheduler.
Interval Gets the time interval which characterizes the current time cell.
Resource Gets the resource of a cell related to the ASPxScheduler.HtmlTimeCellPrepared event.
View Provides access to the Scheduler View.

Remarks

The HtmlTimeCellPrepared event occurs before a time cell is rendered. Handling this event enables you to specify the style and color of a particular time cell, and even insert a Literal control to display text.

Note

Subscribing to the HtmlTimeCellPrepared event automatically disables client-side rendering of view elements.

The following code snippet uses the HtmlTimeCellPrepared event to highlight dinner time.

<dx:ASPxScheduler ID="ASPxScheduler1" runat="server" GroupType="Resource" Start="2008-07-24" 
                  OnHtmlTimeCellPrepared="OnHtmlTimeCellPrepared" >
    <Views>
        <DayView ShowWorkTimeOnly="True">
                <TimeRulers>
                    <cc1:TimeRuler></cc1:TimeRuler>
                </TimeRulers>
        </DayView>
        <WorkWeekView Enabled="false" />
        <MonthView Enabled="false" />
        <TimelineView Enabled="false" />
    </Views>     
</dx:ASPxScheduler>
using DevExpress.Web.ASPxScheduler;
using DevExpress.Web.Internal;
using DevExpress.XtraScheduler;
    protected void OnHtmlTimeCellPrepared(object sender, ASPxSchedulerTimeCellPreparedEventArgs e) {
        TimeInterval cellInterval = e.Interval;
        if (e.View.Type == DevExpress.XtraScheduler.SchedulerViewType.Day) {
            TimeSpan dinnerStart = new TimeSpan(15, 0, 0);
            TimeSpan dinnerEnd = new TimeSpan(17, 0, 0);
            TimeSpan cellStart = cellInterval.Start.TimeOfDay;
            TimeSpan cellEnd = cellInterval.End.TimeOfDay;
            if (cellStart >= dinnerStart && cellStart <= dinnerEnd && cellEnd <= dinnerEnd) {
                e.Cell.BackColor = Color.Red;
                string valueString = HtmlConvertor.ToHtml(Color.Yellow);
                e.Cell.Style.Add("border-bottom-color", valueString);
                e.Cell.Style.Add("text-align", "center");
                e.Cell.Controls.Add(new LiteralControl("dinner"));
            }
        }
        if (e.View.Type == SchedulerViewType.Week) {
            DateTime specialDate = new DateTime(2008, 7, 24);
            if (cellInterval.Start == specialDate) 
                e.Cell.BackColor = Color.Green;
        }
    }
See Also