点击按钮自动弹出对话框自定义地址来保存图片,图片的获取没问题,可就是死活不出对话框。大假帮我看看是什么问题啊 
<anthem:Button ID="btnDwload" runat="server" TextDuringCallBack="downloading..." EnabledDuringCallBack="false"Text="下载照片"  OnClick="btnDwload_Click" CssClass="button_a" />
        FileInfo DownloadFile = new FileInfo(strPhotoPath);
        //strPhotoPath是图片的地址,没有错误的
        Response.Clear();
        Response.ClearHeaders();
        Response.Buffer = false;
        Response.ContentType = "application/octet-stream ";
        Response.AppendHeader("Content-Disposition ", "attachment;filename= "
            + HttpUtility.UrlEncode(DownloadFile.FullName, System.Text.Encoding.UTF8));
        Response.AppendHeader("Content-Length ", DownloadFile.Length.ToString());
        Response.WriteFile(DownloadFile.FullName);
        Response.Flush();
        Response.End(); 
    }

解决方案 »

  1.   


    protected void Button1_Click(object sender, EventArgs e)
        {
            FileInfo fi = new FileInfo(@"c:\1.gif");
            Response.Clear();
            Response.ContentType = "application/octet-stream";
            Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(fi.Name));
            Response.AppendHeader("Content-Length", fi.Length.ToString());
            Response.WriteFile(fi.FullName);
            Response.Flush();
            Response.End();
        }
    上面的代码测试OK,你自己看看吧
      

  2.   

    可是我放在Asp里面 就不能啊