Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6073925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:19:30+00:00 2026-05-23T10:19:30+00:00

I am having to code up a button which, onclick, downloads a csv file

  • 0

I am having to code up a button which, onclick, downloads a csv file onto the client’s computer (this is a web app)

So, did some research, pulled all strings together, go figure, its not working.

I am trying to get this for now:

    protected void btnDownload_onClick(object sender, EventArgs e)
    {
        Response.Clear(); 
        Response.AddHeader("content-disposition", "attachment; filename=tmp.csv");
        Response.ContentType = "text/csv";
        Response.Write("one,two,three,four,five");
        Response.End();
    }

according to a blog that came up on google, that’s all I need to get generate that csv an download it.

only, its not working and I cant figure out what’s wrong with it.

1) firebug inspection: response is EMPTY.
2) VS Debugging, strangely stops after the line Response.End() and complaints that it cant find content.

Am I missing something?
Thanks much. very much.

Edit: I just realized something, this is a child page and there is an update panel in the master page. Can this be the cause of the problem? if so, how can I cancel the ajax postback just for this child page?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T10:19:30+00:00Added an answer on May 23, 2026 at 10:19 am

    reading your comments and edit, looks like you want to cancel ajax postback for just this one button from child page and your update panel is in master page and you can’t access it.

    If I have that details correct, just add this code on your child content page’s PageLoad():

            ScriptManager sm = ScriptManager.GetCurrent(Page);
            if (sm != null)
                sm.RegisterPostBackControl(btnDownload); 
            //btnDownload = the button ID, just copied from your code.
    

    That will force full page postback and your files will be downloaded.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having trouble with this code: NSRect itemFrame; id item; // code to assign
I am having some trouble with this code . The problem is when i
Having problems with IE8... I have a button that onclick fires the showImageBrowser() function.
I've got a Windows Forms Button on a Form which submits a web request.
I have this jquery code to add the onclick event to minimize and maximize
Is there any possibility of having a button which will execute and action in
What's a more elegant way of having the code below where i want to
I'm getting a bit tired of having to code explicitly for multicore if I
Having a strange issue with some C# code - the Getter method for a
I'm having a problem with my Seam code and I can't seem to figure

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.