0

I'm using asp:LinkButton on my page and on click I download a file.But the issues is after I have clicked the download Link Button if I click any other button on the page, it repeats the download action. Can anyone throw some light about why this is happening.

Here is my linked button code

  protected void lnkBtn_Click(object sender, EventArgs e)
  {
        //Download code
  }
Blachshma
  • 17,097
  • 4
  • 58
  • 72
iJade
  • 23,144
  • 56
  • 154
  • 243
  • 2
    What is your code? Give people more clue. – Soner Gönül Jan 02 '13 at 16:32
  • Do you dynamically create your link button in code behind? If so you have to make sure to re-create the button during page load otherwise it gets messy during postback and will work on every other click. – vesuvious Jan 02 '13 at 18:39
  • no i dont create it dynamically – iJade Jan 02 '13 at 19:00
  • I have the opposite problem. Download works fine. Print works fine, but then my download button repeats the print functionality after print is clicked – djack109 Jan 16 '17 at 08:15

1 Answers1

0

This can happens if you have an UpdatePanel somewhere in your page. UpdatePanel modify and remember the viewstate because is wait for replay from this click.

What you do is that you do not return what UpdatePanels waits, because you download a file as you say. So on the next click the UpdatePanel re-send the click because did not have get replay in the first place.

To solve that is better to not download the files with the post back, but with a handler and a link - here is an example: What is the best way to download file from server

Community
  • 1
  • 1
Aristos
  • 66,005
  • 16
  • 114
  • 150