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:
- Poll using Ajax calls to see if the file has been generated.
- 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?