i have a button click event
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
}
}
using this i am trying to download a excel file using reportviewer. On clicking this button i am showing one loading icon(by calling ShowLoading2()) which is defined as a jquery function.
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);
}
I am able to download the report in excel format but not able to call HideLoading2() function from code behind after downloading the excel.
When save("Report1"); method is commented ,able to call HideLoading2().
Here is the save method
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();
}
How can i call the HideLoading2() function after downloading the excel sheet?
Note: I am not using scriptmanager\updatepanel in the page.