Safari and ASP.NET AJAX PageRequestManager.add_endRequest Function does not always work

Here first will be information about the background. ASP.NET 2.0 website with AJAX 1.0 extensions.

I have a weird problem that only occurs in Safari, and I can only assume Chrome, since they both use WebKit. I also use jQuery on the site, but currently the jQuery link only loads on one page, so I don't think this is a problem.

I have a friendly message, "Request Processing ...", which appears when you send an asynchronous or asynchronous postback page) and hides after the postback. In the case of async postback, I use the method PageRequestManager add_endRequest(...)to hide the message "Processing request ...". This works fine in FireFox, IE 6/7/8 and Opera, but for some reason Safari (versions for Windows and Mac) add_endRequest(...)does not always work. I'm all about cross browser, so just wondering if anyone has any ideas on how to fix this.

This is a show stopper for me, because not only the message β€œRequest processing ...” appears, but I also add a transparent div over the whole page to prevent multiple clicks after submitting, so the page becomes unusable if you don’t know how to hack CSS to hide the transparent div.

Here's a snippet of code from my main page markup of what I am doing to process my "Request processing ..." message:

<asp:ScriptManager ID="ScriptManager1" runat="server" />
<script type="text/javascript" src="<%= ResolveClientUrl("~/Script/aspNetAjaxFix.js") %>"></script>
<script type="text/javascript" >
(function() {
    var processingID = "<%=processing.ClientID%>"
    var prm = Sys.WebForms.PageRequestManager.getInstance();

    if (prm)
    {
        prm.add_endRequest(
        function (sender, args) {
            //alert('Fired!')
            if (top['showAsyncProcessingWindow'])
            {
                setTimeout(function(){document.getElementById(processingID).className="LockOff";document.getElementById('processMe').className='processMeLockOff';if(typeof(showIE6Selects)!="undefined"){showIE6Selects();}}, 1000);
                top['showAsyncProcessingWindow'] = false;
            }

            if(args.get_error() && args.get_error().name === 'Sys.WebForms.PageRequestManagerServerErrorException')
            {
                args.set_errorHandled(args._error.httpStatusCode == 0);
            }
        });
    }
})();
</script>

And if you are interested in what aspNetAjaxFix.js is, see this question I posted in StackOverFlow, Interrupt and Delay Operation in Internet Explorer

Of course, I was not lucky with him either. This article seemed to be relevant, http://forums.asp.net/t/1247957.aspx , but only asks the same question, has no solution.

.

+3
2

, , . PageRequestManager add_endRequest(...) , API- ASP.NET AJAX Safari WebKit.

taliesins ASP.NET, http://forums.asp.net/t/1252014.aspx. , , :

Sys.ScriptLoadFailedException: The script 'http://localhost:2241/WebResource.axd?d=hvpXhV5kEMwLgAoaIglURevR_XTtDTBoKZ3aZWWaIvEkBXbLudri1AIv5bRs5f6licjCZMs3Z3MioQLqLTXV98582pKDHkD7BucGkKsPLz41&t=633444640020014740' failed to load. Check for:
Inaccessible path.
Script errors. (IE) Enable 'Display a notification about every script error' under advanced settings.
Missing call to Sys.Application.notifyScriptLoaded().

Sys.Application.notifyScriptLoaded() JavaScript.

.

+4

1-create WebKit.js

Sys.Browser.WebKit = {}; //Safari 3 is considered WebKit
if (navigator.userAgent.indexOf('WebKit/') > -1) {
    Sys.Browser.agent = Sys.Browser.WebKit;
    Sys.Browser.version = parseFloat(navigator.userAgent.match(/WebKit\/(\d+(\.\d+)?)/)[1]);
    Sys.Browser.name = 'WebKit';
}

2-change ScriptManager

 <asp:ScriptManager ID="ScriptManager1" runat="server"         AsyncPostBackTimeout="600">
            <Scripts>
                <asp:ScriptReference Path="~/JScripts/webkit.js" />
            </Scripts>
        </asp:ScriptManager>
0

Source: https://habr.com/ru/post/1710251/


All Articles