Two special days are defined in code-behind - June 26 and 27. In the
property is set for each time slot within the special days boundaries to visually distinguish the special days.
Note, that the special days functionality is achieved using time slots which meet certain criteria. You are not limitted to whole days only. You can set special time slots, for example - highlight the time slot for the current System Time.
javascript
ASPX
CSS
| <style type="text/css"> |
| .Disabled |
| { |
| background: silver !important; |
| cursor: not-allowed; |
| } |
| .Disabled.rsAptCreate |
| { |
| background: silver !important; |
| } |
| </style> |
C#
VB.NET
If you already have an appointment with duration containing the Special Days - you'll need to disable the editing and deleting of this appointment as it is in the category of "disabled". To achieve this you'll need to subscribe to the OnAppointmentDataBound event and use this code:
C#
VB.NET
VARIATIONS
- Set special days or time slots which meet certain criteria. For example, if you don't know in advance the special dates and you need to disable days which don't have any appointments, then modify the code from the attached project as follows:
C#
| private List<DateTime> SpecialDays = new List<DateTime>(); |
| protected void RadScheduler1_TimeSlotCreated(object sender, Telerik.Web.UI.TimeSlotCreatedEventArgs e) |
| { |
| //Check if there are any appointments for the current time slot date: |
| if (RadScheduler1.Appointments.GetAppointmentsInRange(e.TimeSlot.Start.Date, e.TimeSlot.Start.Date.AddDays(1)).Count > 0) |
| { |
| //add this date to the SpecialDays collection |
| SpecialDays.Add(e.TimeSlot.Start.Date); |
| //set your custom css class |
| e.TimeSlot.CssClass = "HasAppointmentsClass"; |
| } |
| else |
| { |
| e.TimeSlot.CssClass = "Disabled"; |
| } |
| |
| } |
VB.NET
| Private SpecialDays As New List(Of DateTime)() |
| Protected Sub RadScheduler1_TimeSlotCreated(sender As Object, e As Telerik.Web.UI.TimeSlotCreatedEventArgs) |
| 'Check if there are any appointments for the current time slot date: |
| If RadScheduler1.Appointments.GetAppointmentsInRange(e.TimeSlot.Start.[Date], e.TimeSlot.Start.[Date].AddDays(1)).Count > 0 Then |
| |
| SpecialDays.Add(e.TimeSlot.Start.[Date]) |
| |
| e.TimeSlot.CssClass = "HasAppointmentsClass" |
| Else |
| e.TimeSlot.CssClass = "Disabled" |
| End If |
| |
| End Sub |
- Highlight the current day.
C#
| protected void RadScheduler1_TimeSlotCreated(object sender, Telerik.Web.UI.TimeSlotCreatedEventArgs e) |
| { |
| if (DateTime.Compare(e.TimeSlot.Start.Date, DateTime.Now.Date) == 0) |
| { |
| e.TimeSlot.CssClass = "CurrentDayStyle"; |
| } |
| |
| } |
| |
| |
VB.NET
| Protected Sub RadScheduler1_TimeSlotCreated(sender As Object, e As Telerik.Web.UI.TimeSlotCreatedEventArgs) |
| If DateTime.Compare(e.TimeSlot.Start.[Date], DateTime.Now.[Date]) = 0 Then |
| e.TimeSlot.CssClass = "CurrentDayStyle" |
| End If |
| End Sub |
- Hightlight the current time slot.
C#
| protected void RadScheduler1_TimeSlotCreated(object sender, Telerik.Web.UI.TimeSlotCreatedEventArgs e) |
| { |
| |
| if ((DateTime.Compare(e.TimeSlot.Start.Date, DateTime.Now.Date)==0)&(e.TimeSlot.Start.Hour == DateTime.Now.Hour)) |
| { |
| e.TimeSlot.CssClass = "CurrentTimeSlotStyle"; |
| } |
| } |
| |
VB.NET
| Protected Sub RadScheduler1_TimeSlotCreated(sender As Object, e As Telerik.Web.UI.TimeSlotCreatedEventArgs) |
| |
| If (DateTime.Compare(e.TimeSlot.Start.[Date], DateTime.Now.[Date]) = 0) And (e.TimeSlot.Start.Hour = DateTime.Now.Hour) Then |
| e.TimeSlot.CssClass = "CurrentTimeSlotStyle" |
| End If |
| End Sub |