I am trying to Download multiple files using asp.net. I have a Button called DownloadFileButton and a ArrayList called FilePath(It holds all the File paths). So when i click
how to overcome this?
In a word (or two), you don't.
HTTP is a request/response system. Any response has to come as a reply to a request. Given that, you can't send multiple responses to a single request. If nothing else, there would be no client listening for those responses (because it already got the response it was waiting for).
So essentially you have two options:
One request = one response.
You can create two or more buttons with asp.net functions to trigger after. For example:
a href="javascript:myFunction1()">Call function /a> asp:Button ID="myButton1" runat="server" Text="Button1" OnClick="myButton1_Click" /> asp:Button ID="myButton2" runat="server" Text="Button2" OnClick="myButton2_Click" /> asp:Button ID="myButton3" runat="server" Text="Button2" OnClick="myButton3_Click" />
To download multiple files you need "a new response", you can do that using $.ajax with jQuery, for example:
function myFunction1() { $.ajax({ url: "myPage.aspx", context: document.body }).done(function () { $("#myButton1").trigger("click"); myFunction2().delay(500000); //delay is necessary }); } function myFunction2() { $.ajax({ url: "myPage.aspx", context: document.body }).done(function () { $("#myButton2").trigger("click"); myFunction3().delay(1000000); }); } function myFunction3() { $.ajax({ url: "myPage.aspx", context: document.body }).done(function () { $("#myButton3").trigger("click"); }); }