在ImageButton Click事件上下载文件

时间:2009-11-03 07:38:06

标签: c# .net file dynamic imagebutton

我有一个文件的链接,我不知道如何将它添加到imagebutton。我想在点击图像按钮时看到'open-save-cancel',屏幕,但是imagebutton似乎没有将文件的链接作为文件,而是将其作为页面URL并打开以打开文件URL作为页面。

由于

1 个答案:

答案 0 :(得分:2)

    //OnClick server Handler

    Response.Clear();
    Response.AddHeader(
        "content-disposition", string.Format("attachment; filename={0}", "file_name"));

    Response.ContentType = "application/octet-stream";

    Response.WriteFile("file_path");
    Response.End();
相关问题