我有使用此我試圖下載使用的ReportViewer一個excel文件按鈕單擊事件jQuery函數後面在asp.net工作不
protected void btndwnReport_Click(object sender, EventArgs e)
{
try
{
save("Report1");
}
catch (Exception ex)
{
Log.Errlog("Error Occured in btndwnReport_Clickof UI_Report Page : " + ex.Message.ToString());
}
finally
{
Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "HideLoading", "HideLoading2();", true);//this function is not triggering
}
}
。在點擊這個按鈕時,我顯示一個加載圖標(通過調用ShowLoading2()),它被定義爲一個jquery函數。
function ShowLoading2() {
try {
if (parent.document.getElementById('dvProgress'))
$("#dvProgress", parent.document).hide();
} catch (e) { }
$("#dvProgress").show();
}
function HideLoading2() {
try {
if (parent.document.getElementById('dvProgress'))
$("#dvProgress", parent.document).hide();
} catch (e) { }
$("#dvProgress").show();
$("#dvProgress").fadeOut(15000);
}
我能下載Excel格式的報告,但不能調用HideLoading2()的代碼功能下載Excel廣告後落後。
保存時(「Report1」);方法被評論,能夠調用HideLoading2()。
這裏是保存方法
public void save(string ReportName)
{
Warning[] warnings;
string[] streamids;
string mimeType, encoding, extension, deviceInfo;
string format = "Excel"; byte[] bytes = null;
deviceInfo = "True";
bytes = rptViewer.ServerReport.Render("EXCEL", null, out mimeType, out encoding, out extension, out streamids, out warnings);
Response.Buffer = false; //transmitfile self buffers
Response.Clear();
Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = "GetReport/excel";
Response.AddHeader("Content-Disposition", "attachment; filename=" + ReportName + ".xls");
Response.OutputStream.Write(bytes, 0, bytes.Length);
Response.OutputStream.Flush();
Response.OutputStream.Close();
Response.Flush();
Response.Close();
}
我如何可以調用下載Excel工作表後HideLoading2()函數?
注意:我沒有在頁面中使用scriptmanager \ updatepanel。
您是否看過您的按鈕回發後的標記,看看JavaScript是否寫入您的頁面? –