ASP.NET 响应时,写入 iframe 完成

ASP.NET On Response.Write to iframe complete

本文关键字:写入 iframe 完成 NET 响应 ASP      更新时间:2023-09-26

我正在开发一个 ASP.NET 应用程序,旨在创建报告并将其下载到客户端。我正在使用发布到服务器的 iframe 执行此操作。操作完成后,将使用 Response.Write() 将报告下载到客户端。

同时,在客户端上,我正在显示一个 GIF 以指示服务器正在生成报告。当报告成功创建并完成写入客户端时,我想相应地更新 iframe,并隐藏 GIF。

有没有办法确定 response.write() 在 iframe 的父页面中是否成功?

父母:

<iframe id="iframe1" src="import-upload.html" width="100%" height="300" onload="loadFrame()" frameborder="0">
function redirect(type) {
        iframe.getElementById('inputType').value = list.options[list.selectedIndex].value;
        iframe.getElementById('inputAction').value = type;
        document.getElementById("divOptionsContainer").style.display = "none";
        document.getElementById("imgLoadingGif").style.display = "";
        iframe.getElementById('frmUpload').submit();
    }

帧源:

<div align="center">
    <form id="frmUpload" action="AjaxFileHandler.aspx" method="POST" enctype="multipart/form-data" target="_self" style="margin-bottom:20px;">
        <input id="fileupload" type="file" name="files[]" />
        <input type="hidden" id="inputAction" name="action"/>
        <input type="hidden" id="inputType" name="type"/>
    </form>
    <button id="btnReport" type="button" onclick="parent.redirect('Report')" style="">Report</button>
    <button id="btnUpload" type="button" onclick="parent.redirect('Import')" style="">Import</button>
</div>

这是我的第一篇文章。如果需要更多信息,请告诉我。提前谢谢。

你可以听onload iframe 的事件:

function redirect(type) {
    iframe.getElementById('inputType').value = list.options[list.selectedIndex].value;
    iframe.getElementById('inputAction').value = type;
    document.getElementById("divOptionsContainer").style.display = "none";
    document.getElementById("imgLoadingGif").style.display = "";
    iframe.onload = function() {
        document.getElementById("divOptionsContainer").style.display = "";
        document.getElementById("imgLoadingGif").style.display = "none";
    }
    iframe.getElementById('frmUpload').submit();
}