New to Telerik UI for ASP.NET AJAX? Start a free 30-day trial
TimeSlotCreated
The TimeSlotCreated event occurs when a time slot is created. TimeSlotCreated has two parameters:
-
sender is the scheduler control.
-
e is an object of type TimeSlotCreatedEventArgs. It has the TimeSlot property.
The TimeSlotCreated
event is not fired after the advanced edit form is opened (it fires before that, and rendering the advanced form renders the scheduler anew). Thus, customizations for the time slots made in the handler are not rendered while the advanced edit form is visible.
Example
The code sample below sets a "Disabled" css style for time slots which have one or more appointments:
C#
protected void RadScheduler1_TimeSlotCreated(object sender, Telerik.Web.UI.TimeSlotCreatedEventArgs e)
{
if (e.TimeSlot.Appointments.Count > 0)
{
e.TimeSlot.CssClass = "Disabled";
}
}
When customizing a Timeslot based on the start time hours, the start time should be converted to the Timezone of the Scheduler, if it is set.
Example
C#
protected void RadScheduler1_TimeSlotCreated(object sender, Telerik.Web.UI.TimeSlotCreatedEventArgs e)
{
RadScheduler scheduler = sender as RadScheduler;
DateTime startdate = e.TimeSlot.Start.Add(scheduler.TimeZoneOffset);
if (startdate.Hour == 8)
{
e.TimeSlot.CssClass += "Disabled";
}
}