<asp:Button />
一部の aDataTable
を Excelにエクスポートするために使用されるaがあります。の生成中に進行状況の画像を表示する必要がありますDataTable
。以下はこれに対する私の試みですが、まだ立ち往生しています。ここでのライフサイクルを理解していない可能性があります。どんな助けにも感謝します。
ASPX
<asp:Button ID="ExportResults" runat="server" UseSubmitBehavior="false" Text="Export Selected" OnClientClick="showWaitingForExport();" OnClick="ExportResults_Click"/>
JavaScript
function showWaitingForExport() {
$("#progressbar").progressbar({ value: false });}
コードビハインド
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();
}