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!
Thank you for your time!
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"
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", ""
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!
Thank you for your time!