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

Issue handling errors from customer database provider

6 Answers 67 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Dwayne
Top achievements
Rank 1
Dwayne asked on 16 Oct 2009, 07:10 PM
I have created a custom database provider. I have a library storing all my database calls using linq. When an exception occurs in my class library that involves the scheduler I can not handle the exception or don't know how to handle the exception be cause the user save event bypasses the scheduler events in the code behind and interacts directly with my custom provider class. Itried checking errors before it sends the appointment to my custom provider but the errors are swallowed. Please help....

6 Answers, 1 is accepted

Sort by
0
Dwayne
Top achievements
Rank 1
answered on 19 Oct 2009, 01:56 PM
I have given up returning the error from my custo provider. What i notice was that the scheduler still executed the page level AppointmentInsert event. So i checked my resource values  if any does not meet my criteria i  cancel the command but when i try to throw up an erro message it gets swallowed and never makes it to the client.
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

 


 

 

 

0
T. Tsonev
Telerik team
answered on 22 Oct 2009, 07:38 PM
Hello,

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.
0
Dwayne
Top achievements
Rank 1
answered on 23 Oct 2009, 02:32 PM
Thank You for your post I was still able to display the error message in a suitable format by using this bit of code


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
0
Dwayne
Top achievements
Rank 1
answered on 23 Oct 2009, 02:50 PM
My final Insert looked like this

 (

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.

 

 

 

0
Chris
Top achievements
Rank 1
answered on 09 Oct 2014, 07:25 PM
Any progress on adding some error handing to the RadScheduler when using a custom data provider? I would like to be able to display a friendly error message to the user if something goes wrong during the call to the provider.

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.
0
Boyan Dimitrov
Telerik team
answered on 14 Oct 2014, 12:47 PM
Hello,

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.

 
Tags
Scheduler
Asked by
Dwayne
Top achievements
Rank 1
Answers by
Dwayne
Top achievements
Rank 1
T. Tsonev
Telerik team
Chris
Top achievements
Rank 1
Boyan Dimitrov
Telerik team
Share this question
or