The following is how you enable a download button on an ASP.NET webform. Sorry but some lines are long and may autowrap.
Just make sure you have a button named "saveAsButton" on your webform and a textfile named "SomeFile.txt" in the same directory as your aspx page to which this codebehind file belongs.
When the user clicks the button, the standard "File Download" box will pop up and the user will be able to choose where to save it. I hope this helps!
Private Sub saveAsButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles saveAsButton.Click
Dim filename As String = "SomeFile.txt"
Dim filepath As String = MapPath(filename)
' In the following line, those are 4 quote marks each
Dim contentString As String = "attachment; filename=" & """" & filename & """"
Response.AddHeader("content-disposition", contentString)
Response.WriteFile(filepath)
Response.End()
End Sub
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.