473,322 Members | 1,501 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

IE File Download Dialog

RN1
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 = "application/octet-stream"
Response.AddHeader("Content-Disposition", "attachment;filename=" &
strURL)

'hdnCurrentDir is a hidden Form element
Response.TransmitFile(hdnCurrentDir.Value & "\" & strURL)
Response.TransmitFile(Path.Combine(hdnCurrentDir.V alue, strURL))
Response.Flush()
Response.End()
End Sub

As such the above code invokes the IE file download dialog
successfully but the problem is in the file download dialog box, if
the user clicks the 'Open' button (instead of clicking the 'Save'
button to save the file in his local machine), then the file opens up
in the same window. I did like the file to open up in a new window.

I am not sure how to go about implementing this. Can someone please
give me some idea on how to do this?

Thanks,

Ron
Aug 8 '08 #1
1 2274
On Aug 8, 11:46*am, RN1 <r...@rediffmail.comwrote:
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 = "application/octet-stream"
* * Response.AddHeader("Content-Disposition", "attachment;filename=" &
strURL)

* * 'hdnCurrentDir is a hidden Form element
* * Response.TransmitFile(hdnCurrentDir.Value & "\" & strURL)
* * Response.TransmitFile(Path.Combine(hdnCurrentDir.V alue, strURL))
* * Response.Flush()
* * Response.End()
End Sub

As such the above code invokes the IE file download dialog
successfully but the problem is in the file download dialog box, if
the user clicks the 'Open' button (instead of clicking the 'Save'
button to save the file in his local machine), then the file opens up
in the same window. I did like the file to open up in a new window.

I am not sure how to go about implementing this. Can someone please
give me some idea on how to do this?

Thanks,

Ron
You can replace the button by a link to the separated webform (e.g.
download.aspx) with target=_blank
Aug 8 '08 #2

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

Similar topics

5
by: peetm | last post by:
I'd like to write to a log whenever a visitor to my site downloads a file. So, I'd like the link they click to be to a php 'page' that returns the file. Don't know how to do that! Side...
0
by: Buddy Ackerman | last post by:
I am trying to implment a file download via a link such that when clicked, instead of starting the default application for that type of file the user will be presented with a download dialog...
7
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...
5
by: Brad | last post by:
In several aspx applications I export crytal reports to pdf, xls and doc files and then the aspx page writes the selected export file to the client browser. This all works with one small quirk: ...
4
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...
2
by: Ken Varn | last post by:
I have an ASP.NET page that incorporates the following code on a button press. private void DownloadTag_Command(object sender, CommandEventArgs e) { FileStream fs; String Filename; Filename...
4
by: Jonny | last post by:
Hello Group How do I open a Save File Dialog from an ASPX page behind a browse button? Any help would be fantastic!! I am using ASP.NET 1.1 using VB.NET as the coding language TIA
1
by: sunita | last post by:
Hiii I open a file download dialog from a modal dialog...From the file download dialog i can either save or open the file.. Is there a way i can let the modal dialog that opens the file download...
1
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.