How to disable the progress bar after downloading the data into excel using C#
i want to hide progress bar after downloading the data into excel.In run mode as follows
i have gridview data from database. i have one Button Export to excel when i click that button gridview data is downloading to excel.
for downloading gridview data to excel code as follows
protected void btnExport_Click(object sender, EventArgs e)
{
System.Threading.Thread.Sleep(3000);
string script = "$(document).ready(function () { $('[id*=btnExport]').click(); });";
ClientScript.RegisterStartupScript(this.GetType(), "load", script, true);
Response.ClearContent();
Response.Buffer = true;
Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", "Employee.xls"));
Response.ContentType = "application/ms-excel";
System.IO.StringWriter sw = new System.IO.StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
gvEmpdetails.AllowPaging = false;
BindGrid();
//Applying stlye to gridview header cells
for (int i = 0; i < gvEmpdetails.HeaderRow.Cells.Count; i++)
{
gvEmpdetails.HeaderRow.Cells[i].Style.Add("background-color", "#df5015");
}
gvEmpdetails.RenderControl(htw);
Response.Write(sw.ToString());
Response.End();
}
Source code as follows
<pre lang="HTML"><html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.modal
{
position: fixed;
top: 0;
left: 0;
background-color: black;
z-index: 99;
opacity: 0.8;
filter: alpha(opacity=80);
-moz-opacity: 0.8;
min-height: 100%;
width: 100%;
}
.loading
{
font-family: Arial;
font-size: 10pt;
border: 5px solid #67CFF5;
width: 200px;
height: 100px;
display: none;
position: fixed;
background-color: White;
z-index: 999;
}
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></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>
</head>
<body>
<form id="form1" runat="server">
<div align ="Center">
<asp:Label ID="label" Text = "Proof of conecpt" Font-Bold ="True" forecolor ="Blue" runat ="server"></asp:Label>
</div>
<asp:GridView ID="gvEmpdetails" runat="server" CellPadding="4" ForeColor="#333333" GridLines="None">
<AlternatingRowStyle BackColor="White" />
<FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
<RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
<SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
<SortedAscendingCellStyle BackColor="#FDF5AC" />
<SortedAscendingHeaderStyle BackColor="#4D0000" />
<SortedDescendingCellStyle BackColor="#FCF6C0" />
<SortedDescendingHeaderStyle BackColor="#820000" />
</asp:GridView>
<div class="loading" align="center">
Loading. Please wait.<br />
<br />
<img src="loader.gif" alt="" />
</div>
<div>
<asp:Button ID="btnExport" runat="server" Text="Export to Excel" OnClick="btnExport_Click" />
</div>
</form>
</body>
</html>
When i click the Exporttoexcel progress bar displaying after that data is displaying into excel.
Then i close the excel. and in the background progress bar is running.
i want to hide that progress bar.
for that how can do.