narasiman rao

narasiman rao

  • NA
  • 519
  • 768.2k

how to show popup when downloading excel file in C#

May 4 2016 10:02 PM
i have gridview data. i have one button called exporttoexcel when i click that button i want to export data into excel.

my code as follows
string attachment = "attachment; filename=GridviewDetails.xls";
Response.ClearContent();
Response.AddHeader("content-disposition", attachment);
Response.ContentType = "application/vnd.ms-excel";
Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";

Response.Write("");
Response.Write("<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">");
Response.Write("<body>");
Response.Write("<table border=1 bordercolor=black>");

Response.Write("<tr>");
Response.Write("<td colspan=5><b><center>");
Response.Write("GirdviewDetails");
Response.Write("</b></center></td>");
Response.Write("</tr>");

System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);

GridView1.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());

Response.Flush();
Response.Write("<table>");
Response.Write("</body>");
Response.Write("</html>");
Response.End();

When i click the export button the excel data is downloading directly,

i want to show popup. in that popup open save is to be there.

When i click the open button excel file to be opened.

When i click the save button excel file to be saved.

for that how can i do in asp.net using C#.

Answers (1)