Using Hyperlink Control for file download

R

rh

Hi,

I am using a Hyperlink control that links to an Excel file. I would like
the "File Download" dialog box to appear instead of the Excel file
automatically opening within the browser.

What do I need to do? Thanks in advance.
 
W

Winista

Instead of providing direct link to XLS file, let the link goto an ASP.Net
page. On that page, read your XLS file from file system and stream it to the
response stream. And set content-type header of response to "octet-stream".
That should do it.

Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment;
filename=myexcelfile.xls");
Response.WriteFile(fileObject);
Response.End();
 

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

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top