Issue handling errors from customer database provider

7 posts, 0 answers
  1. Dwayne
    Dwayne avatar
    41 posts
    Member since:
    Jun 2009

    Posted 16 Oct 2009 Link to this post

    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....
  2. Dwayne
    Dwayne avatar
    41 posts
    Member since:
    Jun 2009

    Posted 19 Oct 2009 Link to this post

    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

     


     

     

     

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. T. Tsonev
    Admin
    T. Tsonev avatar
    2770 posts

    Posted 22 Oct 2009 Link to this post

    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.
  5. Dwayne
    Dwayne avatar
    41 posts
    Member since:
    Jun 2009

    Posted 23 Oct 2009 Link to this post

    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
  6. Dwayne
    Dwayne avatar
    41 posts
    Member since:
    Jun 2009

    Posted 23 Oct 2009 Link to this post

    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.

     

     

     

  7. Chris
    Chris avatar
    5 posts
    Member since:
    Aug 2012

    Posted 09 Oct 2014 in reply to T. Tsonev Link to this post

    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.
  8. Boyan Dimitrov
    Admin
    Boyan Dimitrov avatar
    1746 posts

    Posted 14 Oct 2014 Link to this post

    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.

     
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017