我正在维护旧版VB.Net Webforms应用,添加一个部分后出现了一个奇怪的问题。
这是aspx页面中的这段代码,该页面在执行回发时显示giphy.gif:
<style type="text/css">
.modalWait
{
position: fixed;
top: 0;
left: 0;
background-color: black;
z-index: 99;
opacity: 0.5;
filter: alpha(opacity=80);
-moz-opacity: 0.8;
min-height: 100%;
width: 100%;
}
.loading
{
font-family: Arial;
font-size: 10pt;
/*border: 5px solid #67CFF5;*/
width: 100px;
height: 100px;
display: none;
position: fixed;
background-color: transparent;
z-index: 999;
}
</style>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
function ShowProgress() {
setTimeout(function () {
var modal = $('<div />');
modal.addClass("modalWait");
$('body').append(modal);
var loading = $(".loading");
loading.show();
var top = Math.max($(window).height() / 2 - loading[0].offsetHeight / 2,0);
var left = Math.max($(window).width() / 2 - loading[0].offsetWidth / 2,0);
loading.css({ top: top,left: left });
},200);
}
$('form').live("submit",function () {
ShowProgress();
});
</script>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<form runat="server">
<asp:ScriptManager runat="server"></asp:ScriptManager>
<!-- Page Wrapper -->
<div id="wrapper">
<!-- More Code -->
</div>
<!-- End of Page Wrapper -->
<div class="loading" align="center">
<%--Loading. Please wait.<br /><br />--%>
<img src="../img/giphy.gif" />
</div>
</form>
它对于填充控件的所有查询都非常有效-.gif会在调用数据库时显示,然后消失。
但是后来我添加了一个函数,将datagrid读取为.csv,然后下载。除非我在后面的代码中添加此部分,否则它会完美运行:
Dim bytes As Byte() = Encoding.ASCII.GetBytes(sb.ToString())
Response.Clear()
response.contenttype = "text/csv"
Response.AddHeader("Content-Length",bytes.Length.ToString())
Response.AddHeader("Content-disposition","attachment; filename=contacts.csv")
Response.Write(sb.ToString())
Response.Flush()
Response.End()
文件下载完美...但是giphy.gif仍然存在...即使回发已完成,它也不会消失。
我在做什么错?