IE File Download Dialog

R

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.Value, 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
 
G

Guest

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.Value, 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,528
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top