Using the below Java Script to show the loader once the Export To Excel button is clicked.
<script type="text/javascript">
function showProgress() {
var updateProgress = $get("<%= UpdateProgress1.ClientID %>");
updateProgress.style.display = "block";
}
</script>
<asp:Button ID="btntoExcel" runat="server" Text="Export to Excel" onclick="btntoExcel_Click" OnClientClick="showProgress()" Width="115px"
CssClass="styleShowData" Font-Size="Smaller" />
Everything is working fine but the loader keeps on loading after saving the file in system also.
Don't know how to stop the loader since in JS it is mentioned as
updateProgress.style.display = "block"
Any suggestion will be highly helpful.
Thanks in advance.
Adding Whole Code Below
<%@ Page Language="VB" AutoEventWireup="true" CodeFile="ViewReport.aspx.vb" Inherits="ViewReport" %>
Status Report
<script type="text/javascript">
function showProgress() {
var updateProgress = $get("<%= UpdateProgress1.ClientID %>");
updateProgress.style.display = "block";
}
function hideProgress() {
var updateProgress = $get("<%= UpdateProgress1.ClientID %>");
updateProgress.style.display = "none";
}
</script>
<div runat="server" id="divPopupWindow" align="Left" style="position: relative; top: -11px; left: 0px; background-color: #C8B49B;">
<marquee behavior="alternate"><asp:Label ID="mqHeader1" runat="server" Text="Scrolling Employee Info"></asp:Label></marquee>
<br />
<asp:LoginStatus ID="LoginStatus1" runat="server" />
<br /><br />
<asp:UpdatePanel runat="server" ID="UpdatePanel_1">
<ContentTemplate>
<div runat="server" id="divMyPageWidth_2" align="Left" style="position: relative; height: 10%; left: 0px; background-color: #C8B49B;">
<asp:Button ID="btntoExcel" runat="server" Text="Export to Excel" onclick="btntoExcel_Click" OnClientClick="showProgress()" Width="115px"
CssClass="styleShowData" Font-Size="Smaller" />
<asp:Button ID="btnGotoMainPage" runat="server" Text="Goto Main Page"
Width="118px" CssClass="stGotoMainPage"
Font-Size="Smaller" />
<br />
<table>
<tr>
<td class="style2">
<asp:DropDownList ID="ddlStatusSelection" runat="server">
<asp:ListItem Selected="True">Approved</asp:ListItem>
<asp:ListItem>Pending</asp:ListItem>
<asp:ListItem>Rejected</asp:ListItem>
</asp:DropDownList>
</td>
<td class="style3">
<asp:DropDownList ID="ddlShowRecordsCount" runat="server">
<asp:ListItem Selected="True">25</asp:ListItem>
<asp:ListItem>50</asp:ListItem>
<asp:ListItem>100</asp:ListItem>
<asp:ListItem>200</asp:ListItem>
<asp:ListItem>300</asp:ListItem>
<asp:ListItem>400</asp:ListItem>
<asp:ListItem>500</asp:ListItem>
<asp:ListItem>All</asp:ListItem>
</asp:DropDownList>
</td>
<td>
<asp:Button ID="Button1" runat="server" Text="Show Data"
CssClass="styleShowData" />
</td>
</tr>
</table>
<div runat="server" id="divMyPageWidth" align="Left" style="position: relative; background-color: #C8B49B; overflow: scroll">
<asp:GridView ID="gvScreenToExcel" runat="server" AutoGenerateColumns="false" HeaderStyle-Wrap="True" Height="190px" Width="380px"
BackColor="#DEBA84" BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px"
RowStyle-Wrap="false" Font-Size="Small" >
<FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
<HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" />
<PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
<RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" />
<SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#FFF1D4" />
<SortedAscendingHeaderStyle BackColor="#B95C30" />
<SortedDescendingCellStyle BackColor="#F1E5CE" />
<SortedDescendingHeaderStyle BackColor="#93451F" />
<AlternatingRowStyle BackColor="#FFE7CE" />
<Columns>
<asp:BoundField DataField="Rec_Num" HeaderText="Record #" />
<asp:BoundField DataField="Remarks" HeaderText="Remarks" />
</Columns>
</asp:GridView>
</div>
</div>
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID = "btntoExcel" />
</Triggers>
</asp:UpdatePanel>
<asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel_1">
<ProgressTemplate>
<div class="modal">
<div class="center">
<img alt="" src="Loader.gif" />
</div>
</div>
</ProgressTemplate>
</asp:UpdateProgress>
</div>
</form>
In your code behind inside the btntoExcel_Click event add the following after the export logic is complete.