Save dialogue

J

jimmyfo

Hi, I've got some questions concerning getting the save dialogue to
popup when a link is clicked on. The particular issue I'm having is
that the file is returned dynamically (via a search) and I need to get
the file name for the save dialogue. I've heard that using ADO streams
keeps it from opening in the browser, and forces the popup for
"Save/Open" - does this work?

The ADO stream that I would like to use in the codebehind:

Dim FileName
Dim FullFileName
FileName = "MyWordDocument.doc"
FullFileName = "C:\Webfiles\MyWordDocument.doc"
Response.ContentType = "application/x-unknown"
Response.Addheader "Content-Disposition", "attachment; filename=" &
chr(34) & FileName & chr(34)
Response.Binarywrite GetBinaryFile(FullFileName)

Function GetBinaryFile(ByVal FileSpec)
Const adTypeBinary = 1
Dim objStream
Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open()
objStream.Type = adTypeBinary
objStream.LoadFromFile (FileSpec)
GetBinaryFile = objStream.Read()
Set objStream = Nothing
End Function

Now how do I make the TemplateColumn in the ASP.Net portion linked, or
run this particular code? or is there a better way?

My column:
<asp:TemplateColumn
ItemStyle-HorizontalAlign="Center"><ItemTemplate><asp:Image ID="thumb"
runat="server" /></ItemTemplate></asp:TemplateColumn>

Do I use an anchor element? Some DataItem element? I need to get the
filename via the codebehind, so it needs to happen there. The filename,
thumbnails, etc are all grabbed in the DataGrids ItemDataBound
function.

Thanks!
James
 
P

Patrice

#1 This an ASP group. Try an ASP.NET group for more details...
#2 The name is given by you in the filename part (not sure what you meant by
"I need to get the file name")
#3 This is the content-disposition header that allows to force the download
dialog, not using ADODB.Stream (it just a way to copy data to the HTTP
response)
#4 ASP.NET has a Response.WriteFile method, not need to use an
ADODB.Stream.... (or a .NET stream you should have used anyway) unless
perhaps if the file is huge.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top