Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.Net/Jquery find client event after Response.End()

Tags:

jquery

asp.net

I have a button that is generating a PDF file on the server and then setting the response header information to the client for the file to be downloaded.

I would like to display a "Please Wait..." message during the postback because it could be time intensive. I'm able to display a div with no problem when the button is clicked but I'm not able to hide this div when the server returns the information.

Below is my server side code:

Response.Buffer = true;
Response.Charset = "";
Response.AddHeader("content-disposition", "attachment; filename=" + Casefile.SerialCode + ".ppt");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = "application/octet-stream";
Response.BinaryWrite(binaryData);
Response.Flush();
Response.End();

I've tried the following Jquery to hide my Div but it never gets called...

$(document).onLoad(function ()
{
   $('#divLoading').css("display", "none");
});
like image 853
Miles Avatar asked Jan 01 '26 00:01

Miles


1 Answers

I do the exact same thing with this:

        $(document).ready(function () {
            $('#inProgress').hide();
        });

EDIT You can try using the clientscriptmanager on your server side.

ClientScriptManager.RegisterStartupScript(this.GetType(), "HideDiv", "$('#inProgress').hide();", true)

alternatively you can try something like:(in your javascript)

        Sys.Application.add_init(appl_init);

        function appl_init() {
            var pgRegMgr = Sys.WebForms.PageRequestManager.getInstance();               
            pgRegMgr.add_endRequest(EndHandler);
        }

        function EndHandler() {           
            $('#inProgress').hide();
        }
like image 154
Etch Avatar answered Jan 02 '26 15:01

Etch



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!