Ajax error handling

  • Thread starter Thread starter Programer
  • Start date Start date
P

Programer

I use timer control which executes some code on server side event named
Timer1_Tick.
If user disconect internet connection, this page show error alert window. I
can not put try catch block in timer_thick event because it is server side
and internet connection is closed.

How to catch this error on client side?
 
I use timer control which executes some code on server side event named
Timer1_Tick.
If user disconect internet connection, this page show error alert window.I
can not put try catch block in timer_thick event because it is server side
and internet connection is closed.

How to catch this error on client side?

Try this

try
{
//your code goes here
}
catch(err)
{ }

Cheers,
_Ratnesh
S7 Software
 
Sorry, but I need catch on client side. I need to catch ajax error which is
generated by ScriptManager.
How can I catch ScriptManager errors if my page is loaded and comp is
offline?
 
Sorry, but I need catch on client side. I need to catch ajax error which is
generated by ScriptManager.
How can I catch ScriptManager errors if my page is loaded and comp is
offline?

that is client side javascript code.. :)

Regards,
-Ratnesh
 
Hi,

I am by no means an expert in this area, but one think that might work is to
handle the endRequest event on the client side PageRequestManager object.

This can be wired up using
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(MyEndRequestHandler).
Where MyRequestHandler is a JavaScript function that is called at the end of
a the async AJAX request, you could check for the error condition in this
function and handle it gracefully.

Hope this helps,
 
Hi,

Chris Taylor was corect. anyway i am giving the complete code, add this in
your aspx or ascx file.

<script>

Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);

function EndRequestHandler(sender, args) {
if (args.get_error() != undefined) {
if ((args.get_response().get_statusCode() == '12007') ||
(args.get_response().get_statusCode() == '12029')) {
alert('Connection Problem');
args.set_errorHandled(true); //added so that the
error will not come
}
}
}
</script>



Thanks and Regards
Arijit Chatterjee
 
Hi,

Chris Taylor was corect. anyway i am giving the complete code, add this in
your aspx or ascx file.

<script>

Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);

function EndRequestHandler(sender, args) {
if (args.get_error() != undefined) {
if ((args.get_response().get_statusCode() == '12007') ||
(args.get_response().get_statusCode() == '12029')) {
alert('Connection Problem');
args.set_errorHandled(true); //added so that the
error will not come
}
}
}
</script>



Thanks and Regards
Arijit Chatterjee
 
Back
Top