﻿Sys.Application.add_load(AppLoad);

function AppLoad() {
    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequest);
    Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(BeginRequest);
}
function BeginRequest(sender, args) {
    // Clear the error if it's visible from a previous request.
    if ($get('Error').style.visibility == "visible")
        CloseError();
}

function EndRequest(sender, args) {
 $(':disabled').css("color","red");
    // Check to see if there's an error on this request.
    // Let the framework know that the error is handled, 
    //  so it doesn't throw the JavaScript alert.
    args.set_errorHandled(true);
    if (args.get_error() != undefined) {
        // If there is, show the custom error.
        $get('Error').style.visibility = "visible";
        $('html, body').animate({ scrollTop: 0 }, 0);
        // Let the framework know that the error is handled, 
        //  so it doesn't throw the JavaScript alert.
        args.set_errorHandled(true);
    }
}

function CloseError() {
    // Hide the error div.
    $get('Error').style.visibility = "hidden";
    location.reload(true);
}
