I am using custom advanced form to maintain appointment. The database thorows an exception if the validation fails. The validation is complex that I cannot bring it to the client side. Currently the application shows "Server error in '/<app>' Application" with the error message returned by the database. How can I catch the exception and show in RadAlert? Any help is appreciated.
Thanks, E.Z.
Thanks, E.Z.
4 Answers, 1 is accepted
0
Andrew
Top achievements
Rank 1
answered on 10 May 2010, 04:22 PM
I would really love to know the answer to this as well. I am in the same boat as you!!!!
Not sure if I can change fields in AppointmentToInsert and AppointmentToUpdate in my datasource, but I was thinking of creating a custom attribute called Error, and if after Appointment Insert/Updated, this field is populated, then do a RadAlert with that message (Not forgetting to clear the message in javascript on the client side). However, I don't see a client side event called "OnClientAppointmentInserted" to be called after the appointment is inserted. So that may not be feasible.
Not sure if I can change fields in AppointmentToInsert and AppointmentToUpdate in my datasource, but I was thinking of creating a custom attribute called Error, and if after Appointment Insert/Updated, this field is populated, then do a RadAlert with that message (Not forgetting to clear the message in javascript on the client side). However, I don't see a client side event called "OnClientAppointmentInserted" to be called after the appointment is inserted. So that may not be feasible.
0
Andrew
Top achievements
Rank 1
answered on 11 May 2010, 11:47 PM
I figured out a solution to this problem:
In the RadScriptManager in my scheduler control page I code the following:
ErrorHandler.js has my error handler script which is:
To validate on the server side, I setup the RadScheduler with:
Then in my routines RadScheduler1_OnAppointmentInsert and RadScheduler_OnAppointmentUpdate, when I throw an exception it is caught by my EndRequestHander, and an alert box displays the error message (without the class description of the exception).
Hhope this helps someone.
In the RadScriptManager in my scheduler control page I code the following:
<telerik:RadScriptManager runat="server" ID="RadScriptManager1"> |
<scripts> |
<asp:ScriptReference Path="/Scripts/AdvancedForm.js" /> |
<asp:ScriptReference Path="/Scripts/ErrorHandler.js" /> |
</scripts> |
</telerik:RadScriptManager> |
ErrorHandler.js has my error handler script which is:
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler); |
function EndRequestHandler(sender, args) { |
if (args.get_error() != undefined) { |
var msg = args.get_error().message; |
alert(msg.substring(msg.indexOf(":", 0) + 1)); |
args.set_errorHandled(true); |
} |
} |
To validate on the server side, I setup the RadScheduler with:
OnAppointmentInsert="RadScheduler1_OnAppointmentInsert" |
OnAppointmentUpdate="RadScheduler1_OnAppointmentUpdate" |
Then in my routines RadScheduler1_OnAppointmentInsert and RadScheduler_OnAppointmentUpdate, when I throw an exception it is caught by my EndRequestHander, and an alert box displays the error message (without the class description of the exception).
Hhope this helps someone.
0
Peali
Top achievements
Rank 1
answered on 26 Jun 2012, 09:33 AM
Need more explanation and demo application on the server side error handling from front end.
0
Hi Peali,
Plamen Zdravkov
the Telerik team
You can throw some custom exception in the GetAppointments of MyDbSchedulerProvider as it is done in the attached project.
If you are trying to achieve something different please elaborate a little bit to we can be more helpful.
Plamen Zdravkov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.