6 Answers, 1 is accepted

This is an example of my code to check my resource values which i retreived on ITEM COMMAND which gets executed before most commands
Private Sub RadScheduler1_AppointmentInsert(ByVal sender As Object, ByVal e As Telerik.Web.UI.SchedulerCancelEventArgs) Handles RadScheduler1.AppointmentInsert
Try
Dim err As String = ""
e.Appointment.Resources.GetResourceByType(
"Users").Text = Membership.GetUser.UserName
If Me.LocationCombox.ToString.Equals("") Then
err = err +
" Location Required <br/>"
End If
If Me.ActivityCombox.ToString.Equals("") Then
err = err +
" Activity Required <br/>"
End If
If Me.ColorCombox.ToString.Equals("") Then
err = err +
" Color Required <br/>"
End If
If Me.CalendarCombox.ToString.Equals("") Then
err = err +
" Calendar Required <br/>"
End If
If Not err.Equals("") Then
Throw New ArgumentNullException(err)
End If
Catch ex As Exception
Page.ClientScript.RegisterStartupScript(
Me.GetType(), "MyScript", _
"function AlertHello() { alert(' " + ex.Message + "'); }", True)
e.Cancel =
True
End Try
End Sub
Indeed returning error information directly from the provider is not yet supported. We're planning on improve the provider interface and we'll include error handling as well.
The best place to do validation is in the AppointmentInsert/Edit events as you've correctly assumed.
The JavaScript that shows the error message is probably not executing because you're updating the page with AJAX. In this case you need to use ScriptManager.RegisterStartupScript instead of ClientScript.RegisterStartupScript.
I think you don't need to throw exceptions in this case. Canceling the event and showing an error message is sufficient.
Greetings,
Tsvetomir Tsonev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.

ScriptManager.RegisterStartupScript(
Me.RadScheduler1, Me.GetType(), "MyScript", "function AlertHello() { }", True)
RadAjaxManager1.ResponseScripts.Add(
"radalert('" + err.ToString + "', 330, 210);")
e.Cancel =
True
I nneded both the scriptmanger call and the response script to dispaly the message one without the other didn't work.
Thanks

(
Private Sub RadScheduler1_AppointmentInsert(ByVal sender As Object, ByVal e As Telerik.Web.UI.SchedulerCancelEventArgs) Handles RadScheduler1.AppointmentInsert
e.Appointment.Resources.GetResourceByType(
"Users").Text = Membership.GetUser.UserName
'custom error string function
If Not ErrorString().Equals("") Then
'custom error handling sub
ThrowUpError(ErrorString.ToString())
e.Cancel =
True
'custom clear variables sub
clearVariables()
Else
Dim returnresult As Boolean
'this call check the user inserting the calendar for permission to do so
If Not getUserResult(Membership.GetUser.UserName, 0, CalendarCombox.ToString.Replace(" ", ""), returnresult) Then
Dim err As String
err =
"Cannot insert because it does not belong to user : " + Membership.GetUser.UserName + "<br/>"
ThrowUpError(err)
e.Cancel =
True
Else
clearVariables()
End If
End If
End Sub
)
Enjoy the scheduler is very versitle is if you can figure it out.

Using the control-level events are OK for validation - but what about exceptions thrown from the provider? I'm forced to use the generic error screen if I don't have the RadScheduler wired up for AJAX - and if it *is* wired up, there is no way to show the user that an error occurred.
At this point we have not done error handling to the RadScheduler when using a custom data provider. The only solution for now is using the RadScheduler control level events for validation.
Regards,
Boyan Dimitrov
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.