JQuery BlockUI - How to unblock UI after file download?

Posted by Dan on Stack Overflow See other posts from Stack Overflow or by Dan
Published on 2009-03-25T21:35:39Z Indexed on 2010/06/01 23:03 UTC
Read the original article Hit count: 654

Filed under:
|
|
|

Using ASP.Net, JQuery and BlockUI, I'm trying to unblock the UI after a download file dialog is shown.

I block the UI when export button is clicked:

   <script type="text/javascript">     
    $(document).ready(function(){        
        $('#<%= BtnExport.ClientID%>').click(function(){
            $.blockUI(); 
        });
    });    
    </script>

After this, I generate the file server side using:

        private void SendFileToUser(byte[] file, string contentType, string filename)
        {
            Response.Clear();
            Response.ContentType = contentType;
            Response.AppendHeader("Content-Disposition", "attachment; filename="+filename);
            Response.OutputStream.Write(file,0,file.Length);
            Response.OutputStream.Flush();   
            Response.End();
        }

After this code has executed, I would like to unblock the UI.

I have considered different options:

  1. Poll using Ajax calls to see if the file has been generated.
  2. Store the file in Session and redirect to same page and generate download then.

But both options seem ackward, and I think there must be a clever JavaScript way to get a handle on or wait for a file dialog.

Any suggestions?

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about JavaScript