473,387 Members | 1,545 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

creating a csv file for download inside page callback

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

Mar 5 '08 #1
2 1402
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

"bbdobuddy" <bb*******@discussions.microsoft.comschreef in bericht
news:FB**********************************@microsof t.com...
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
Mar 5 '08 #2
bbdobuddy wrote:
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..?

--

(O)enone
Mar 5 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Inpreet | last post by:
Hello I am using: ************************************************************************* header("Content-Type:application/force-download",false); header("Content-Disposition: attachment;...
4
by: Jeff Cooper | last post by:
There must be something I'm missing. No else else seems to have this issue -- at least I don't see it mentioned anywhere. (Also, my appologies for my earlier posts in which I mistakenly referred...
3
by: A.M | last post by:
Hi, Using ASP.NET/VB.NET and SQL Server backend, I need to return calculation results to user as an Access MDB file or Excel XLS sheet. What would be the best way to create a MDB or XLS file...
0
by: tom | last post by:
Hallo, I need help on MIDI file, and precisely about retrieving few note values (mainly the "Velocity" value, corrisponding to the intensity of a played note) while the MIDI is playing.
3
by: Uncle_Bob | last post by:
Hello all! I'm writing a simple C# application, that should day by day open a particular web site and download a text file (new file is generated by the server daily). I'm using Microsoft Web...
1
by: Timbo | last post by:
Hi all, This is my first message here so i'll try and include all the information that will help you help me out, if possible. Basically I am using C# in ASP.NET 2.0 and have a Repeater...
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
3
by: pd | last post by:
guys, in my web app, i have a simple download button and a href which points to a file on my server, when the user clicks on the button or the link, the file should simply be downloaded to the...
4
by: Roberto Mora | last post by:
I have not done programming in a very long time and what is worst, I never learned VB. Although my job does not require this knowledge, I cam across a problem that although it seemed simple it has...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.