download file in

Posted on 2009-04-22
Last Modified: 2013-11-08
I'm using following code to download file. the problem is onupdate event of UpdatePanelAnimationExtender is not calling. Seeking help


<asp:ScriptManager ID="ScriptManager1" runat="server">


  <cc1:UpdatePanelAnimationExtender ID="UpdatePanelAnimationExtender1" runat="server"




        <FadeOut Duration=".5" Fps="18" MinimumOpacity=".5" />


        <OnUpdated><FadeIn Duration=".5" Fps="18" /></OnUpdated>




    <asp:UpdatePanel ID="Up1" runat="server" UpdateMode="Conditional">


 <asp:Button SkinID="brownish" ID="btnLabelTop" runat="server" Text="Label" OnClick="btnLabelTop_Click"  />




            <asp:AsyncPostBackTrigger ControlID="btnLabelTop" EventName="Click" />







button click code 

 protected void btnLabelTop_Click(object sender, EventArgs e)




-some code--


Response.Redirect("Download.aspx", true);





 protected void Page_Load(object sender, EventArgs e)




            DownloadFile("labels.csv", true);


        catch (Exception ex)




    /// <summary>

    /// Download csv file

    /// </summary>

    /// <param name="fname"></param>

    /// <param name="forceDownload"></param>

    private void DownloadFile(string fname, bool forceDownload)


        string path = Server.MapPath(Request.ApplicationPath) + "\\csv\\" + fname;

        string name = Path.GetFileName(path);

        string ext = Path.GetExtension(path);

        string type = "";

        // set known types based on file extension  

        if (ext != null)


            switch (ext.ToLower())


                case ".csv":

                    type = "text/csv";


                case ".txt":

                    type = "text/plain";


                case ".doc":

                case ".rtf":

                    type = "Application/msword";


                case ".pdf":

                    type = "Application/pdf";




        if (forceDownload)


            Response.AppendHeader("content-disposition", "attachment; filename=" + name);

            Response.AppendHeader("Content-Transfer-Encoding", "binary");

            Response.Expires = 0;

            Response.AppendHeader("Pragma", "cache");

            Response.AppendHeader("Cache-control", "private");


        if (type != "")

            Response.ContentType = type;




Open in new window

Question by:chrisy
    1 Comment
    LVL 14

    Accepted Solution


    You have put UpdateMode="Conditional" in UpdatePanel declaration. If you are using Conditional, the update panel will not update until you call UpdatePanel1.Update();

    Try this.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
    Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    737 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

    19 Experts available now in Live!

    Get 1:1 Help Now