You must Sign In to post a response.
  • Category: ASP.NET

    When open excel i want to show popup

    I am exproting the gridview data to excel.

    it is downloading directly.

    i want to show the popup before downloading.

    My code as follows

    Response.Clear();
    Response.Buffer = true;
    Response.ClearContent();
    Response.ClearHeaders();
    Response.Charset = "";
    string FileName = "Employeess.xls";
    StringWriter strwritter = new StringWriter();
    HtmlTextWriter htmltextwrtter = new HtmlTextWriter(strwritter);
    Response.Cache.SetCacheability(HttpCacheability.NoCache);
    Response.ContentType = "application/vnd.ms-excel";
    Response.AddHeader("Content-Disposition", "attachment;filename=" + FileName);
    gvEmpdetails.GridLines = GridLines.Both;
    gvEmpdetails.HeaderStyle.Font.Bold = true;
    gvEmpdetails.RenderControl(htmltextwrtter);
    Response.Write(strwritter.ToString());
    Response.End();

    in my above code when i export the gridview to excel. gridview data is exproting into excel.

    but before exproting into excel i want to show popup as follows

    Yes No Cancel

    for that how can i do in asp.net using C#.
  • #765816
    download a file and open file is a client browser application, asp.net does not have any control on it, when browser prompt for download it has 3 button
    1. save
    2. Open
    3. cancel
    here if you click on open, the browser will open a file in temp folder and remove it when you close file, when you click on save it will save it in specified location
    I don't think there is a way to open a file after download

    Thanks
    Koolprasd2003
    Editor, DotNetSpider MVM
    Microsoft MVP 2014 [ASP.NET/IIS]

  • #765833
    Hi,

    I never tried this combination but I tried it separately, use modalpopupextender control in AJAX to achieve the confirmation with Yes / No option.
    You have to do more customization to achieve this task, while click save you need to perform the saving the file into temporary location same like for open you need to perform opening the file for one instance.

    please use below link to show the confirmation before perform any action.

    http://www.dotnetspider.com/resources/46217-ModalPopupExtender-with-Yes-No-options-without-postback.aspx

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/


  • Sign In to post your comments