Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic Download Problem

Status
Not open for further replies.

Joulius

Programmer
Dec 16, 2003
215
RO
I have a small ASP.NET project with an Access DataBase.
On one page I have a dynamic table created and populated from the access database. On every table row I have created buttons that once they are clicked, a specific file should be downloaded. I must add that the file(s) are .zip format.
In example for one instance, here's how I did it:
*DR is a DataReader already created and the code below is inside a while DR.Read loop*

Dim btnDL As New Button()
Dim sp = Server.MapPath(".\download\")
Dim dlFile = sp & DR.Item("ID") & ".zip"
If Not File.Exists(dlFile) Then
btnDL.Enabled = False
End If
AddHandler btnDL.Click, AddressOf btnDL_Click
btnDL.ID = "DL" & DR.Item("ID")
btnDL.Text = "Download"

Private Sub btnDL_Click(ByVal sender As System.Object, ByVal e As EventArgs)
Dim sp = Server.MapPath(".\download\")
Dim dlUrl = sp & Replace(sender.ID, "SUB", "") & ".zip"
Response.Redirect(dlUrl)
End Sub

This is what I have for now. I know it's stupid, but this is what I have. I've already tryed the HyperLink possibility with target="_blank" and it works too, but for some reason I don't want that the one is downloading the file to know the location of the file on my server. What I want in fact is, once the download button is clicked, the "Save As..." dialog to appear. I don't know if this is possible, but I hope it is! :D

Thank you for your time!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top