controlling a downloaded filename

  • Thread starter Thread starter Bob Weiner
  • Start date Start date
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
 
hi bob
i use this in my script

Response.AddHeader "content-disposition", _
"attachment; filename=""" & strFileName & """"
 
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
 
Back
Top