Asp.net Update Progress - Export To Excel - Java Script Issue
Asp.net Update Progress - Export To Excel - Java Script Issue
Using the below Java Script to show the loader once the Export To Excel button is clicked.
function showProgress() {
var updateProgress = $get("");
updateProgress.style.display = "block";
}
<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"
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
function showProgress() {
var updateProgress = $get("");
updateProgress.style.display = "block";
}
function hideProgress() {
var updateProgress = $get("");
updateProgress.style.display = "none";
}
Approved
Pending
Rejected
25
50
100
200
300
400
500
All
</div>
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID = "btntoExcel" />
</Triggers>
</asp:UpdatePanel>
<asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel_1">
<ProgressTemplate>

</div>
</ProgressTemplate>
</asp:UpdateProgress>
</div>
</form>
This question has not received enough attention.
1 Answer
1
Add hideProgress()
javascript function. Call that function from server side from btntoExcel_Click
function using ScriptManager.RegisterClientScriptBlock
or ScriptManager.RegisterStartupScript
.
hideProgress()
btntoExcel_Click
ScriptManager.RegisterClientScriptBlock
ScriptManager.RegisterStartupScript
Once response comes from the code behind btntoExcel_Click
function it will execute script passed from ScriptManager.RegisterClientScriptBlock
or ScriptManager.RegisterStartupScript
.
btntoExcel_Click
ScriptManager.RegisterClientScriptBlock
ScriptManager.RegisterStartupScript
You can also bind to an event in client side code (JavaScript) every time an UpdatePanel has finished like this Sys.WebForms.PageRequestManager.getInstance().add_endRequest(function(){ hideProgress(); });
:
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(function(){ hideProgress(); });
HTML Code:
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(function() { hideProgress(); });
function showProgress() {
var updateProgress = $get("");
updateProgress.style.display = "block";
}
function hideProgress() {
var updateProgress = $get("");
updateProgress.style.display = "none";
}
Code Behind:
protected void btntoExcel_Click(object sender, EventArgs e)
{
// Add following code At the end of the function
// ScriptManager.RegisterClientScriptBlock(this, GetType(), "none", "hideProgress();", false);
ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "script", "hideProgress();", false);
}
<asp:Button ID="btntoExcel" runat="server" Text="Export to Excel" onclick="btntoExcel_Click" OnClientClick="showProgress()" Width="115px" CssClass="styleShowData" Font-Size="Smaller" />
Ohh sorry, It was typing mistake,
ScriptManager.RegisterClientScriptBlock
line need to put at the end of your btntoExcel_Click
function. Updated the answer.– Karan
19 hours ago
ScriptManager.RegisterClientScriptBlock
btntoExcel_Click
I applied your new code but still the loader keeps on running :(
– Sixthsense
19 hours ago
Try once with RegisterStartupScript. Code is updated accordingly.
– Karan
19 hours ago
Ji, Still loader is running after saving the file :(
– Sixthsense
19 hours ago
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
I don't have any control named as btnLogin
– Sixthsense
19 hours ago