导出到Excel后显示/隐藏加载图像而不使用更新面板 [英] Show/Hide Loading Image after Export to Excel without using Update Panel
本文介绍了导出到Excel后显示/隐藏加载图像而不使用更新面板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经搜索了半天寻找答案但没有成功。我在这里试试运气。
我的aspx没有更新面板。
用户点击导出到Excel后我成功显示进度条但在Respond.End之后它永远不会隐藏起来。
有什么方法可以解决这个问题吗?
这是代码:
用于显示进度条的Javascript
I have googled around for half day searching for the answer but no success. Im trying my luck here.
My aspx does not have update panel.
I succeed to show progress bar after user click Export to Excel but it never hides back after Respond.End.
Is there any method to solve the problem?
Here's the codes:
Javascript to show progress bar
<script src="jquery-1.8.3.min.js" type="text/javascript"></script>
<script type="text/javascript">
function ShowProgress() {
setTimeout(function () {
var modal = $('<div />');
modal.addClass("modal");
$('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>
代码隐藏(页面加载)
Code behind (Page Load)
ClientScript.RegisterStartupScript(Me.[GetType](), "load", "$(document).ready(function () { $('[id*=btnExport]').click(); });", True)
代码落后(导出到Excel)
Code behind (Export to Excel)
Dim style As String = "<style> .text { mso-number-format:'#,##0.000_);[Red](#,##0.000)';text-align:right; } </style> "
HttpContext.Current.Response.Clear()
HttpContext.Current.Response.AddHeader("content-disposition", String.Format("attachment; filename={0}", fName))
HttpContext.Current.Response.ContentType = "application/ms-excel"
HttpContext.Current.Response.ClearContent()
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.Unicode
HttpContext.Current.Response.BinaryWrite(System.Text.Encoding.Unicode.GetPreamble())
HttpContext.Current.Response.Write(style)
Using sw As New StringWriter()
Dim hw As New HtmlTextWriter(sw)
'To Export all pages
For Each row As GridViewRow In gv.Rows
'For Each cell As TableCell In row.Cells
For i As Integer = 0 To row.Cells.Count - 1
Dim str As String = row.Cells(i).Text
If i > 7 Then
row.Cells(i).Attributes.Add("class", "text")
End If
Next
Next
pnl.RenderControl(hw)
HttpContext.Current.Response.Write(sw.ToString())
End Using
HttpContext.Current.Response.Flush()
HttpContext.Current.Response.SuppressContent = True
HttpContext.Current.ApplicationInstance.CompleteRequest()
Response.[End]()
推荐答案
('< div / > ');
modal.addClass(modal);
('<div />'); modal.addClass("modal");
('body')。append(modal);
var loading =
('body').append(modal); var loading =
(。loading);
loading.show();
var top = Math.max(
(".loading"); loading.show(); var top = Math.max(
这篇关于导出到Excel后显示/隐藏加载图像而不使用更新面板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文