【问题标题】:Download file on ImageButton Click event在 ImageButton Click 事件上下载文件
【发布时间】:2009-11-03 07:38:05
【问题描述】:

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

谢谢

【问题讨论】:

    标签: c# .net file dynamic imagebutton


    【解决方案1】:
        //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();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-01-17
      • 1970-01-01
      • 2013-04-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多