Click here to Skip to main content
15,887,822 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have to display a modal pop up until the file gets downloaded.Soon after the file download completes, a confirm box is opened,asking if the download was successful or not? How can I achieve this? any suggestion is appreciated.
I used this code to send excel to response object...I have been using epplus.

asp.net 4.0 c#

C#
worksheet.Tables[0].ShowFilter = true;

                HttpContext.Current.Response.ClearHeaders();
                HttpContext.Current.Response.ClearContent();
                HttpContext.Current.Response.Clear();
               // HttpContext.Current.Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
                HttpContext.Current.Response.ContentType = "application/x-msexcel";
                HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + strfileName + ".xlsx");
                HttpContext.Current.Response.AddHeader("Content-Length", package.GetAsByteArray().Length.ToString());
                //HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8");
                HttpContext.Current.Response.ContentEncoding = System.Text.UTF8Encoding.UTF8;
                if (HttpContext.Current.Response.IsClientConnected)
                {
                    HttpContext.Current.Response.BinaryWrite(package.GetAsByteArray());
                }
                HttpContext.Current.Response.Flush();
                HttpContext.Current.Response.Close();
Posted

1 solution

You can achieve this by having a IFrame on the page. Steps would be as such:

1. User Clicks on file download button, Set src of IFrame to a URL which downloads the file.
2. Detect that iframe has loaded successfully, many implementation available.
3. When Load even occurs execute confirm java-script function to ask user about the success of download.

I hope it helps.

Thanks
Rohit
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900