Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > File Download Button

Thread Tools

File Download Button

Posts: n/a
Hi All,

I have built an application that allows a user to download a file from the
server. I would like to come up with a solution that works with all html
standard compliant browsers in addition to IE6 and IE7. I would like to
avoid leaving an empty open popup window on the screen, and even though I
have a captive user audience that can be required to disable popup blockers
and set security settings to trusted sites, I would like to avoid requiring
users to do this as much as possible.

My current solution is to call this function on a button click:

function ShowFile(strFileName)
var reportFrame = self.frames['reportframe'];
var loadingDiv = document.getElementById('Loadingmsg');
reportFrame.location="blank2.html"; = 'block';
var goURL = "default.ashx?CLASSNAME=SHOWFILE2&FNAME="+strFileN ame+"";
reportFrame.location=goURL; = 'none';
the ASHX code behind the page is as follows:

this.CurrentContext.Response.ContentType = "application/octet-stream";
"attachment; filename=" + strDisplayFileName);
On the web from there is a hidden div containing an anmiated gif that
displays while the file is loading. There is also an iFrame on the page
which is initially loaded with a blank html page with no borders set so it
is invisible. The function works on all browsers for the most part, but some
users have settings set up in such a way that for certain types of files
(like text file) the file shows up in the iFrame instead of promting the
user for downloads.

Before this I was popping up a window with javascript, and then the window
was redirecting to the file, and closing itself. This worked OK for a long
time but the IE6 came on on XP SP2 and the popup blocker would disable the
fiole download and allow the window to close without the user ever seeing
the file.

Do you folks have any examples of a good standard practive for a file
download button?


Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Forcing Download of File Appends HTML from Download Page to Downloaded File? Brett Kelly ASP .Net 1 06-16-2006 04:05 AM
problem with code download file - two window file download Sam -- ASP .Net 2 03-17-2005 04:20 PM
Re: How can I display a download link in my (C#) ASP.NET web form to download a file stored in my sql db? Steve C. Orr [MVP, MCSD] ASP .Net 0 03-07-2005 07:14 PM
File upload/download from database. Download appends aspx page to end of file Ryan Taylor ASP .Net 2 11-10-2004 08:31 PM