nooruls143 Posted September 13, 2006 Posted September 13, 2006 Hi, I need to create a page that enables the user to download the files from his directory depending upon his username. So, each user has its own specific directory. I have been able to display the files using DataGrid and put a download button next to each row (Asp:ButtonColumn) but I am unable to trigger the download. I have created a subroutine that enables the download using file streams, and I want the button to trigger that sub whenever the user clicks on it. Please help! Also plz. provide the code if possible Regards, Noorul Quote
Gill Bates Posted September 28, 2006 Posted September 28, 2006 What you need to do is create an Http Handler (.ashx) file. You can pass the file path to this handler in the QueryString. You then need to set the appropriate value for the ContentType property of the HttpResponse. Here's an example for an MS Word document:byte[] bytes = null; // your file bytes here... context.Response.ContentType = "application/ms-word"; context.Response.AddHeader("content-disposition", "inline;filename=test.doc"); context.Response.BinaryWrite(bytes);Look around online for "HTML Content Type" for the right value for your specific file type. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.