Another "Virtual File" question.

T

Terry Olsen

I followed the information in a previous thread, but i'm having
problems.

I have a couple dropdownlists and a submit button on my form. The user
selects choices from the lists and clicks the submit button. The app
then places the data requested into a string variable.

I want to send this data out to the client and have the save dialog
prompt him to save it as a file. Here's the code.

' Variable csvOut is a string that contains my data.
With Response
.ContentType = "text/csv"
.AddHeader("content-disposition", "attachment;
filename=NetopImport.txt")
.Write(csvOut)
End With

1. When the save dialog appears on the client, if I click "Save" then
it saves the file. I open the file to find my data at the top, but then
the page source follows that.

2. If I click "Open" on the save dialog, the save dialog appears a 2nd
time and I click open again. Notepad opens and I see my data followed by
the page source.

Any help is appreciated. Thanks!
 
C

Chris Simmons

In other words, after the dropdown and submit button action, you want
the page to outputting your string and then stop processing, correct?
If so, I think you'll just need to add a .End() after your
..Write(csvOut). However, to be safe, I'd also clear the content of the
Response buffer as well. Here's the result:

' Begin code
' Variable csvOut is a string that contains my data.
With Response
.ClearContent()
.ContentType = "text/csv"
.AddHeader("content-dispositio­n",
"attachment;filename=NetopImport.txt")
.Write(csvOut)
.End()
End With

' End code

Does that do what you want?
 
T

Terry Olsen

Yup, the .End did the trick. I was just about to post that I'd figured
out that part of it. Thanks.

But now, why, when I click "Open" in the Save Dialog do I get presented
with another Save Dialog instead of the file opening in Notepad? Once I
click "Open" a second time, then Notepad opens up.
 
C

Chris Simmons

Try a .ClearHeaders() in there right after .ClearContent()

See if that does it.
 

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

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,273
Latest member
DamonShoem

Latest Threads

Top