controlling a downloaded filename

B

Bob Weiner

Can I control the name of a file downloaded if that file name isn't in a
request header?


I have a data grid that contains a list of excel files by date. In each row
there is a ButtonColumn pointed at a handler containing the code:

case "Download":
Response.ContentType = "Application/x-msexcel";
Response.TransmitFile(e.Item.Cells[0].Text);
Response.End();
break;

It works, but the filename offered to the client is always the name of the
aspx file with the extension replaced with .xls. Can I make the name of the
xls file offered to the client the same as it is on the server?

It seems like it should be simple enough to do but I've been searching for
the correct method, property, header without success.

Thanks,
bob
 
D

dave bray

hi bob
i use this in my script

Response.AddHeader "content-disposition", _
"attachment; filename=""" & strFileName & """"
 
B

Bob Weiner

thanks. works like a champ!

bob


dave bray said:
hi bob
i use this in my script

Response.AddHeader "content-disposition", _
"attachment; filename=""" & strFileName & """"

Bob said:
Can I control the name of a file downloaded if that file name isn't in a
request header?


I have a data grid that contains a list of excel files by date. In each
row there is a ButtonColumn pointed at a handler containing the code:

case "Download":
Response.ContentType = "Application/x-msexcel";
Response.TransmitFile(e.Item.Cells[0].Text);
Response.End();
break;

It works, but the filename offered to the client is always the name of
the aspx file with the extension replaced with .xls. Can I make the name
of the xls file offered to the client the same as it is on the server?

It seems like it should be simple enough to do but I've been searching
for the correct method, property, header without success.

Thanks,
bob
 

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

Forum statistics

Threads
473,994
Messages
2,570,222
Members
46,810
Latest member
Kassie0918

Latest Threads

Top