1

I have an application that downloads files from within a gridview. When a single file is attached to a row I can easily download the files but when I try to have multiple files within a row my application can no longer download. Could anybody possibly suggest a way I could accomplish this?

Thanks in advance

imdondo
  • 132
  • 2
  • 12
  • Try zipping the files. http://geekswithblogs.net/twickers/archive/2005/11/08/59420.aspx – NoLifeKing Jul 06 '12 at 07:20
  • Is it possible to do it without zipping the files first since this is the initial requirement. – imdondo Jul 06 '12 at 07:28
  • If there are multiple files, why add them in the same row? Can't you show those in another girdview? On row selection probably? – nunespascal Jul 06 '12 at 07:29
  • One thing would be to make a queue (in javascript) that downloads all the files, one at the time. Are you familiar with jQuery? – NoLifeKing Jul 06 '12 at 07:29
  • My Javascript skills are not that good. Regarding the files bieng on the same role that's because they all are attached to the same id for that particular row. The situation is it can be a single file or more files. – imdondo Jul 06 '12 at 07:51

1 Answers1

1

When user click and as to download a file you can give this javacript command

window.location = "FileForDownload.jpg";

If you won to give the user the ability to download more than one files is more complicate.

Firs you must need to know that the browser will alert that action and stop it until user accept the multiple downloads.

Now you could easy say that you can send many files at window.location but if this happens with out synchronization then the one file can stop the other. The synchronization here can be done with this trick of cookies and give the command the second download only after the first have been start (or end).

One more solution is to call the window.open("FileForDownload.jpg"); many times (with a timer delay of course) that is not need synchronization.

This is a general idea in javascript, but need some improvement to open the files with a delay.

function DownloadAllFiles()
{
    for (var i=0; i< arguments.length; i++){    
        window.open( "http://www.domain.com/downloadpath/" + arguments[i]);)
    }
}


// example of call
DownloadAllFiles("File1.zip","File2.zip","File3.zip");
Community
  • 1
  • 1
Aristos
  • 66,005
  • 16
  • 114
  • 150
  • I like your approach, it's simple and still doesn't need jQuery. Also, you could add the code to initiate the javascript from Code behind aswell. :) – NoLifeKing Jul 06 '12 at 08:38