Hi Doug,
The best thing is a LinkButton control. If you use the following technique,
the user will have no idea where the file is coming from but it looks just
like a hyperlink:
Private Sub LinkButton1_Click _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles LinkButton1.Click
Dim FilePath As String = "C:\downloads\setup.exe"
Dim FileName As String = "setup.exe"
'Set the appropriate ContentType.
Response.ContentType = "application/octet-stream"
Response.AddHeader("Content-Disposition", _
"attachment; filename=" & FileName)
'Write the file directly to the HTTP output stream.
Response.WriteFile(FilePath)
Response.End()
End Sub
<form id="Form1" method="post" runat="server">
<asp:LinkButton id="LinkButton1" runat="server">Click to
download</asp:LinkButton>
</form>
"Doug Stiers" <st****@email.com> wrote in message
news:eH**************@TK2MSFTNGP10.phx.gbl...
I have a button on a webform, when the user clicks a file on our network
will be downloaded to the clients machine. I need the button to initiate
the download just like a hyperlink without displaying the path like a
hyperlink would (down on the status bar). The file is an exe so its not something
that is going to be displayed, it has to be downloaded.
I've tried Server.Transfer(sFilePath) but that does not work. Can anyone
help?
Thanks,
Doug Stiers