Sys.Application.add_init(AppInit);
 
function AppInit(sender) {
  Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndErrorHandler);
}
 
function EndErrorHandler(sender, args)
{
   if (args.get_error() != undefined)
   {
      if ((args.get_response().get_statusCode() == '12007') || (args.get_response().get_statusCode() == '12029'))
      {
         // If the error is a connectivity issue, we ignore the error.
         args.set_errorHandled(true);
      }
      else if (args.get_error().name == "Sys.WebForms.PageRequestManagerServerErrorException")
      {
        args.set_errorHandled(true);
      }

   }
}
