Another "Virtual File" question.

  • Thread starter Thread starter Terry Olsen
  • Start date Start date
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!
 
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?
 
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.
 

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

Back
Top