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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

file download problems

Status
Not open for further replies.

mikemardon

Programmer
May 23, 2005
71
GB
Hi there

I have created a template column in my datagrid which contains hyperlinks - when clicked they use the following code to pick up a file for download :

NavigateUrl='<%# DataBinder.Eval(Container, "DataItem.FileURL") %>

the problem I have is that the files open IN the browser, instead of opening the dialogue box (open/save/cancel).

I know that I need to use some code to change the way that the file is interpreted by the browser but I only know how to do this with server side code. Can anyone help me out?

Thanks!
 
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


I dont know if this helps, but it works
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top