That seems to solve the problem of bringing up the dialog box, however, it
does not seem to be letting me generate the file the way I want. The code I
am using is:
Private Sub btnDownload_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnDownload.Click
Dim mystreamwriter As System.IO.TextWriter
mystreamwriter = Response.Output
mystreamwriter.WriteLine("This is a test download text file")
mystreamwriter.Write(Date.Now.ToLongDateString() & " " &
Date.Now.ToLongTimeString())
mystreamwriter.Close()
Response.AddHeader("content-disposition", "attachment;
filename=download.txt")
End Sub
This code brings up the dialog box, but saves only the code that you would
see if you looked at the browser's View->Source. If I place the code at the
very beginning of the Page_Load procedure, then the generated text is placed
at the beginning of the file, but everything else is still included with it.
I realize I could make a separate file that has nothing other than the code
to generate the file and bring up the download dialog, but I would like to
be able to have the user click a button, have the file generated, and then
have the download dialog come up without creating a separate .aspx file.
What do I need to do differently? Thanks.
--
Nathan Sokalski
nj********@hotmail.com http://www.nathansokalski.com/
"Thomas Egginger" <T.Egginger@__gmx__.net> wrote in message
news:eE*************@TK2MSFTNGP09.phx.gbl...
response.addHeader "content-disposition", "attachment;
filename=filename.ext"
should do the work...
"Nathan Sokalski" <nj********@hotmail.com> schrieb im Newsbeitrag
news:ej**************@TK2MSFTNGP09.phx.gbl...I want to give visitors to my site the option of downloading a generated
.txt file by clicking a button. I know how to generate text files, but how
do I cause the browser to pop up one of those dialog boxes that says
something like "Do you want to download FILEX.txt?" I want the user to be
able to download the file rather than have the file displayed in the
browser, because the file will include some characters such as tabs and
commas. The purpose of the text file is a tab delimited text file, and I
do not want the browser modifying any of the characters. Any ideas?
Thanks.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/