iframe onload does not work to stop spinner here. To do this, you will need cookies and the client side of the script. The server code sets the value in the cookie. When the report is displayed, the value will be read on the client side (cshtml), and the counter can be stopped.
Read this article. Here you can replace the blocker with a counter.
http://gruffcode.com/2010/10/28/detecting-the-file-download-dialog-in-the-browser/
$(document).ready(function () {
$('#create_pdf_form').submit(function () {
blockUIForDownload();
});
});
function blockUIForDownload() {
var token = new Date().getTime();
$('#download_token_value_id').val(token);
$.blockUI();
fileDownloadCheckTimer = window.setInterval(function () {
var cookieValue = $.cookie('fileDownloadToken');
if (cookieValue == token)
finishDownload();
}, 1000);
}
function finishDownload() {
window.clearInterval(fileDownloadCheckTimer);
setCookie("fileDownloadToken", '2')
$.unblockUI();
}
var response = HttpContext.Current.Response;
response.Clear();
response.AppendCookie(new HttpCookie("fileDownloadToken",
downloadTokenValue);
form submit via the hidden input field
response.Flush();
<script src="~/Scripts/jquery-1.5.1.js"></script>
<script src="~/Scripts/jquery.blockUI.js"></script>
<script src="~/Scripts/jquery.cookie.js"></script>
source
share