473,785 Members | 2,414 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

File Download Button

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(strFil eName)
{
var reportFrame = self.frames['reportframe'];
var loadingDiv = document.getEle mentById('Loadi ngmsg');
reportFrame.loc ation="blank2.h tml";
loadingDiv.styl e.display = 'block';
var goURL = "default.ashx?C LASSNAME=SHOWFI LE2&FNAME="+str FileName+"";
reportFrame.loc ation=goURL;
loadingDiv.styl e.display = 'none';
}
_______________ _______________ ____
the ASHX code behind the page is as follows:

this.CurrentCon text.Response.C lear();
this.CurrentCon text.Response.C ontentType = "applicatio n/octet-stream";
this.CurrentCon text.Response.A ddHeader("Conte nt-Disposition",
"attachment ; filename=" + strDisplayFileN ame);
this.CurrentCon text.Response.F lush();
CurrentContext. Response.WriteF ile(strLocalPat h);
_______________ _______________ _______________ _
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
Nov 21 '06 #1
0 1511

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2584
by: jmd | last post by:
Hello. I want to write a C# program that does completely automatically what, until now, I do manually, witch is describe below : 1. I launch IE (6) 2. I browse to my desired download page, say http://www.site.com/download This download page contains some textboxes, checkboxes, radiobuttons, a DOWNLOAD BUTTON and text 3. I check some checkboxes, select some radiobuttons, enter text in some textboxes and click on the download button
0
1945
by: karunakar | last post by:
Hi All I am not able to read the class name I want read the particular class name string path = System.Configuration.ConfigurationSettings.AppSettings; string className = path + ".User"; return (SCS.SR.IDAL.IUser) Assembly.Load(path).CreateInstance(className); ( This line iam getting Error)
7
3706
by: theyas | last post by:
How can I get my code to NOT display two "Open/Save/Cancel/More Info" dialog boxes when using the "Response.WriteFile" method to download a file to IE I've asked about this before and didn't get a satisfactory answer (check your browser) so now that I've had the time to set up a reasonable little test that I can post somewhere, I'll try again. The app I've written has three ASPX pages. One is a combined page which writes a little text...
1
5401
by: Roy | last post by:
Hi, I have a problem that I have been working with for a while. I need to be able from server side (asp.net) to detect that the file i'm streaming down to the client is saved completely/succsessfully on the client's computer before updating some metadata on the server (file downloaded date for instance) However, All examples i have tried, and all examples I have found that other people says works - doesn't work for me :-(
4
2335
by: Nathan Sokalski | last post by:
I want to give visitors to my site the option of downloading a generated ..txt file by clicking a button. I know how to generate text files, but how do I cause the browser to pop up one of those dialog boxes that says something like "Do you want to download FILEX.txt?" I want the user to be able to download the file rather than have the file displayed in the browser, because the file will include some characters such as tabs and commas....
18
16407
by: jmd | last post by:
Hello, I posted the following in the C# forum but without one answer. But perhaps now in vb.net someone has some guidelines ! This is my question : I want to write a vb.net program that does completely automatically what, until now, I do manually, witch is describe below : 1. I launch IE (6)
2
2173
by: msxkim | last post by:
My web app writes some binary data to a file at the client site via Response.BinaryWrite. This action is accomplished in response to a button click, with C# code behind as follows: private void SubmitButton_Click (object sender, System.EventArgs e) { // Set up the response to write the print file to the client Response.Clear (); Response.Buffer=false;
3
2474
by: pd | last post by:
guys, in my web app, i have a simple download button and a href which points to a file on my server, when the user clicks on the button or the link, the file should simply be downloaded to the users machine. now this file is a postgres backup file with the .backup extension. now when i use the button, in FF the file download button pops up and i can save the file, i can also right click the href and go save link as. and it works fine.
1
1292
by: rohit3291 | last post by:
Friends i need your help on the below issue please help me urgent...... Thanks in advance... I have a web site where i have a button called report. On click of report button some data is being written in to a html file and a new window appears as expected.Here in this new window i have two frames.In the first frame i am displaying the html file and in the bottom frame 3 other buttons are there. one is "save", second is "print" and third...
1
2296
by: RN1 | last post by:
In an ASP.NET app, users can upload their files to a remote server as back-up. I want to give users the provision to download files that they have uploaded to the remote server to their local machine. This is how I am invoking the file download dialog box that pops up in IE6 (users click a Button): Sub btn_DwnldFile(ByVal obj As Object, ByVal ea As EventArgs) Dim strURL As String = 'getting the file name Response.ContentType =...
0
9646
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9483
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10346
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10157
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10096
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9956
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7504
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5514
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2887
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.