This is a migrated thread and some comments may be shown as answers.

How to hardcode RecurrenceRule Exceptions

1 Answer 66 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Albert
Top achievements
Rank 1
Albert asked on 24 Feb 2009, 07:29 AM
Im stuck on adding the exceptions even though the RecurrenceRule i made has the EXDate. So how exactly do i make exception rules? Thanks

1 Answer, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 25 Feb 2009, 12:59 PM
Hello Albert,

The RecurrenceRule class exposes an Exceptions collection to which you can add DateTime objects to create exceptions for specific date and time. For example, suppose you need to create a recurring appointment starting on February 8, 2009 at 9:00am which is one hour long, occurs daily for five days. Now, suppose that you don't want the appointment to occur on February 10. You can achieve this by handling the AppointmentInsert event as follows:

 protected void RadScheduler1_AppointmentInsert(object sender, Telerik.Web.UI.SchedulerCancelEventArgs e)  
    {  
        if (e.Appointment.RecurrenceRule != String.Empty)  
        {  
            RecurrenceRule rrule;  
            RecurrenceRule.TryParse(e.Appointment.RecurrenceRule, out rrule);  
            rrule.Exceptions.Add(new DateTime(2009, 2, 10, 9, 0, 0).ToLocalTime());  
            e.Appointment.RecurrenceRule = rrule.ToString();  
        }  
    } 



Kind regards,
Peter
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Scheduler
Asked by
Albert
Top achievements
Rank 1
Answers by
Peter
Telerik team
Share this question
or