By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,738 Members | 1,730 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,738 IT Pros & Developers. It's quick & easy.

Another "Virtual File" question.

P: n/a
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!

*** Sent via Developersdex http://www.developersdex.com ***
Nov 19 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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?

Nov 19 '05 #2

P: n/a
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.
*** Sent via Developersdex http://www.developersdex.com ***
Nov 19 '05 #3

P: n/a
Try a .ClearHeaders() in there right after .ClearContent()

See if that does it.

Nov 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.