On theOnDownloadI set that will navigate to the next form in the website for export xls file
protectedvoidOnDownload(object sender, EventArgs e)
{
Button btn = (Button)sender;
GridViewRow row = btn.NamingContainer as GridViewRow;
string ese = (row.FindControl("hfCountry") as HiddenField).Value;
if (!string.IsNullOrEmpty(ddl.SelectedValue))
{
Response.Redirect("xls.aspx?e=" + ese.ToString() + "&a=" + ddl.SelectedValue);
}
else
{
Response.Redirect("xls.aspx?e=" + ese.ToString());
}
}
With this code my problem is after downloading the excel file from the page xls.aspx my loading screen it does not close and remains fixed on the browser...
With this code my problem is after downloading the excel file from the page xls.aspx my loading screen it does not close and remains fixed on the browser...
You seem to want the page to automatically close the page after the download file response is complete?
If this is the case, I think you can try it like this:
But in chrome browser, you can't close the page by script, you can only do it manually.
The code works on IE and Edge, or you can choose to return to the previous page after the download is complete.
Best regards,
Xudong Peng
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
Member
23 Points
36 Posts
After downloading file the loading screen it does not close ASP NET C#
Feb 20, 2021 11:54 AM|Edward Sheriff Curtis|LINK
Hi,
I have add a
Button
inGridView
<asp:ScriptManager runat="server" /> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false"> <Columns> <asp:BoundField DataField="Name" /> <asp:TemplateField HeaderText="" ItemStyle-HorizontalAlign="Center"> <ItemTemplate> <asp:HiddenField ID="hfCountry" runat="server" Value='<%# Eval("Country") %>' /> <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel1"> <ProgressTemplate> <div class="modal"> <div class="center"> <img alt="" src="progress.gif" /> </div> </div> </ProgressTemplate> </asp:UpdateProgress> <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional"> <Triggers> <asp:AsyncPostBackTrigger ControlID="Link" EventName="Click" /> </Triggers> <ContentTemplate> <asp:Button ID="Link" runat="server" Text="Download" OnClick="OnDownload" CssClass="buttonLink" /> </ContentTemplate> </asp:UpdatePanel> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> <style type="text/css"> body { margin: 0; padding: 0; font-family: Arial; } .modal { position: fixed; left: 0; z-index: 999; height: 100%; width: 100%; top: 0; background-color: Black; filter: alpha(opacity=60); opacity: 0.6; -moz-opacity: 0.8; } .center { z-index: 1000; margin: 30px auto; padding: 10px; width: 130px; background-color: White; border-radius: 10px; filter: alpha(opacity=100); opacity: 1; -moz-opacity: 1; } .center img { height: 128px; width: 128px; } .buttonLink { background: none !important; border: none; padding: 0 !important; font-family: arial, sans-serif; color: #069; text-decoration: underline; cursor: pointer; } </style>
On the
OnDownload
I set that will navigate to the next form in the website for export xls fileprotected void OnDownload(object sender, EventArgs e) { Button btn = (Button)sender; GridViewRow row = btn.NamingContainer as GridViewRow; string ese = (row.FindControl("hfCountry") as HiddenField).Value; if (!string.IsNullOrEmpty(ddl.SelectedValue)) { Response.Redirect("xls.aspx?e=" + ese.ToString() + "&a=" + ddl.SelectedValue); } else { Response.Redirect("xls.aspx?e=" + ese.ToString()); } }
With this code my problem is after downloading the excel file from the page xls.aspx my loading screen it does not close and remains fixed on the browser...
How to do resolve this?
Thanks in advance for any help
Contributor
2080 Points
664 Posts
Re: After downloading file the loading screen it does not close ASP NET C#
Feb 22, 2021 09:39 AM|XuDong Peng|LINK
Hi Edward Sheriff Curtis,
You seem to want the page to automatically close the page after the download file response is complete?
If this is the case, I think you can try it like this:
But in chrome browser, you can't close the page by script, you can only do it manually.
The code works on IE and Edge, or you can choose to return to the previous page after the download is complete.
Best regards,
Xudong Peng