Solved click button and download a file

Posted on 2011-10-28
Last Modified: 2012-06-21
I have some code that will create an excel file on the server.  How do I make it so that a button click will make the client open a save dialogue box so the user can download the file?
Question by:jackjohnson44
    1 Comment
    LVL 11

    Accepted Solution

    in a button click event:


    Response.ContentType = "application/ms-excel";
    //can also be "inline" instead of "attachment" to display immediately
    Response.AddHeader("Content-Disposition", "attachment; filename=DefaultSaveName.xls");
    //you could also copy bytes to Reponse.OutputStream


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    794 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now