469,910 Members | 1,466 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,910 developers. It's quick & easy.

Save dialogue

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

Aug 16 '06 #1
1 1442
#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.

--
Patrice

<ji*****@gmail.coma écrit dans le message de news:
11**********************@m73g2000cwd.googlegroups. com...
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

Aug 16 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Kit Truong | last post: by
3 posts views Thread by Amy | last post: by
6 posts views Thread by Thomas Schoch | last post: by
reply views Thread by jimmyfo | last post: by
1 post views Thread by Waqarahmed | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.