This may do what you want (here file names for download are listed in a
radio button list)
Dim filepath As String
Dim filename As String
If Me.RadioButtonList1.SelectedIndex <> -1 Then
filename =
Me.RadioButtonList1.Items(Me.RadioButtonList1.Sele ctedIndex).Text
filepath = Server.MapPath(".") & "\downloads\" & filename
Else
Exit Sub
End If
Response.Clear()
Response.ContentType = "application/octet-stream"
Response.AddHeader("Content-Disposition", _
"attachment; filename=""" & filename & """")
Response.WriteFile(filepath)
"Do" <do*************@hotmail.com> wrote in message
news:eC*************@tk2msftngp13.phx.gbl...
Hi,
My issue is twofold.
1) How do I invoke a "save file" action when a user clicks a button.
In classic ASP, I used to response.redirect to file path. But I want
to keep the user on the same page they clicked "Download" button.
2) How do I force to prompt for a save file when the user clicks the
button rather than try to open and read the file in the browser, which is the
default action.
Thanks,
Do