Hello,
I think I am in need of some basics.
I am looking over this demo and within the example code, I don't understand what the arguments represent within the GetResource method:
protected void RadScheduler1_AppointmentInsert(object sender, SchedulerCancelEventArgs e) {
if (e.Appointment.Resources.Count < 1)
e.Appointment.Resources.Add(RadScheduler1.Resources.GetResource("Calendar", "1"));
}
When I look at the DefaultCS.aspx included with the demo, I see where there is a title for a <div> set to "Calendar". That's the only object I see named as "Calendar". That being the case, I don't understand what GetResource is referring, and I don't understand what the second argument ("1") means either. Therefore, I don't know how to translate this demo into what I am trying to do.
What I want to do is add appointments to MSExchange. Right now, my page containing a RadScheduler is capable of displaying appointments that were already added to Exchange via Outlook. What I want to do is add the appointments via the scheduler control, instead of thru Outlook. But on my page, when I try to execute the command-line containing the GetResource method, I encounter a Null exception as follows:
System.ArgumentNullException was unhandled by user code
Message=Value cannot be null.
Parameter name: value
Source=System.Web
ParamName=value
StackTrace:
at System.Web.UI.StateManagedCollection.OnValidate(Object value)
at System.Web.UI.StateManagedCollection.System.Collections.IList.Add(Object value)
at Telerik.Web.StronglyTypedStateManagedCollection`1.Add(ItemType item)
at _Schedule.radScheduler_AppointmentInsert(Object sender, SchedulerCancelEventArgs e)
at Telerik.Web.UI.RadScheduler.OnAppointmentInsert(AppointmentInsertEventArgs args)
at Telerik.Web.UI.RadScheduler.ProcessPostBackCommand(SchedulerPostBackEvent postBack)
at Telerik.Web.UI.RadScheduler.RaisePostBackEvent(String eventArgument)
at Telerik.Web.UI.RadScheduler.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
InnerException:
I believe the Add method is what actually fails, since GetResource is returning a Null. But I don't know what to plug in as valid arguments for GetResource(). I've tried what I think would be logical values, all of which have resulted in the same Null exception. Here is my latest event method:
protected void radScheduler_AppointmentInsert(object sender, SchedulerCancelEventArgs e) {
GenericCollection<ExchangeAPI.Calendar> calAppts = ExchangeAPI.Calendar.GetAll(this.txtUsername.Text,
this.radScheduler.VisibleRangeStart,
this.radScheduler.VisibleRangeEnd);
radScheduler.DataSource = calAppts;
radScheduler.DataBind();
if (e.Appointment.Subject == String.Empty) {
e.Cancel = true;
}
else {
//this.radScheduler.InsertAppointment(e.Appointment);
if (e.Appointment.Resources.Count < 1)
//e.Appointment.Resources.Add(radScheduler.Resources.GetResource("Calendar", "1"));
e.Appointment.Resources.Add(radScheduler.Resources.GetResource(radScheduler.DataSourceID, "1"));
}
The error always occurs on the last command-line that you see above. BTW, I use practically the same code (as above) to display the existing appointments in the RadScheduler. The only thing I am doing differently in the above event is that I am including the command to insert a new appointment, and that is the command that fails.
I am sure that I am mis-understanding some basics here. Can someone please help?
Thanks,
Steven