Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB.NET / March 2008

Tip: Looking for answers? Try searching our database.

creating a csv file for download inside page callback

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
bbdobuddy - 05 Mar 2008 00:27 GMT
Hi,

I have a callback that is being called in which I need to create a csv file
that the user can download.

I have the string created correctly but the download prompt dialog box is
not appearing

Here is the last piece of code that should do the download

               strFileName = Session("SourceLayer").ToString().Replace(" ",
"_") + DateTime.Now.Year.ToString() + month + day + ".csv"

               Response.AddHeader("Content-disposition", "attachment;
filename=" + strFileName)
               Response.ContentType = "text/plain"
               Response.Write(csvText)
               Response.Flush()
               Response.End()

Any help would be appreciated
Cor Ligthert[MVP] - 05 Mar 2008 04:50 GMT
Hi,

It is again a while ago that I did this, bus as far as I remember me you
need if you want to download something to set your file on the server and
give the user the link to that using that text control with the option
"File" or just use the a linklabel.

Cor

> Hi,
>
[quoted text clipped - 19 lines]
>
> Any help would be appreciated
(O)enone - 05 Mar 2008 09:33 GMT
> Here is the last piece of code that should do the download
[...]

I just looked at some of my own code that does what you're trying to do, and
the only differences I can spot are:

- my code also provides a name in the ContentType:

   Response.ContentType = "text/plain; name=""filename.txt"""

(actually my code isn't using text/plain as its mime type but I don't see
why that should result in different behaviour).

- my code performs a Response.BinaryWrite instead of Response.Write, as it's
sending binary data instead of text. Again I don't see why that would cause
different behaviour, though.

So try adding the name to the ContentType and see if that makes any
difference..?

Signature

(O)enone


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.