How to Download Multiple Files using ASP.NET?

后端 未结 2 1383
别那么骄傲
别那么骄傲 2020-12-11 22:03

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

2条回答
  •  既然无缘
    2020-12-11 22:37

    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");
            });
        }
    
    

提交回复
热议问题