B
bill
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";
loadingDiv.style.display = 'block';
var goURL = "default.ashx?CLASSNAME=SHOWFILE2&FNAME="+strFileName+"";
reportFrame.location=goURL;
loadingDiv.style.display = 'none';
}
__________________________________
the ASHX code behind the page is as follows:
this.CurrentContext.Response.Clear();
this.CurrentContext.Response.ContentType = "application/octet-stream";
this.CurrentContext.Response.AddHeader("Content-Disposition",
"attachment; filename=" + strDisplayFileName);
this.CurrentContext.Response.Flush();
CurrentContext.Response.WriteFile(strLocalPath);
______________________________________________
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?
Thanks
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";
loadingDiv.style.display = 'block';
var goURL = "default.ashx?CLASSNAME=SHOWFILE2&FNAME="+strFileName+"";
reportFrame.location=goURL;
loadingDiv.style.display = 'none';
}
__________________________________
the ASHX code behind the page is as follows:
this.CurrentContext.Response.Clear();
this.CurrentContext.Response.ContentType = "application/octet-stream";
this.CurrentContext.Response.AddHeader("Content-Disposition",
"attachment; filename=" + strDisplayFileName);
this.CurrentContext.Response.Flush();
CurrentContext.Response.WriteFile(strLocalPath);
______________________________________________
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?
Thanks