I have a <asp:Button />
which is used to export some a DataTable
into Excel. I need to display a progress image while the DataTable
is being generated. Below is my try for this but still stuck. May be I haven't understand the life cycle here. Appreciate any help.
ASPX
<asp:Button ID="ExportResults" runat="server" UseSubmitBehavior="false" Text="Export Selected" OnClientClick="showWaitingForExport();" OnClick="ExportResults_Click"/>
JavaScript
function showWaitingForExport() {
$("#progressbar").progressbar({ value: false });}
Code Behind
protected void ExportResults_Click(object sender, EventArgs e)
{
DataTable resultDT = GenerateDataTable(); //This is the time taking function and after this I need to hide my progressbar while response still not get end
ScriptManager.RegisterStartupScript(this, this.GetType(), "stopprogress", "$('#progressbar').progressbar('destroy');", true);
string filename = "Search_Results.xlsx";
workbook.AddWorksheet(resultDT, "Search Results");
workbook.SaveAs(Server.MapPath("~/Temp/" + filename));
Response.ContentType = "application/vnd.ms-excel";
Response.AppendHeader("Content-Disposition", "attachment; filename=" + filename + "");
Response.TransmitFile(Server.MapPath("~/Temp/" + filename));
Response.End();
}