472,145 Members | 1,639 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,145 software developers and data experts.

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 1483
#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
reply views Thread by Saiars | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.