JQuery BlockUI - How to unlock user interface after file upload?

Using ASP.Net, JQuery, and BlockUI, I try to unlock the user interface after the file download dialog is displayed.

I block the user interface when I click the export button:

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

After that, I create 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 executing this code, I would like to unlock the interface.

I considered different options:

  • A polling using Ajax causes whether a file has been generated.
  • Store the file in the session and redirect it to the same page and then upload.

But both options seem true, and I think there must be a smart JavaScript way to get a handle or wait for a dialog with a file.

Any suggestions?

+3
3

, . "" " ...". , www.download.com , .

, - , POST, .

0

The method I used is to send a cookie in addition to a file attachment that you can detect with a timeout using JavaScript, and then unlock ui

Details here http://geekswithblogs.net/GruffCode/archive/2010/10/28/detecting-the-file-download-dialog-in-the-browser.aspx

0
source

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


All Articles