首先入口是abc.aspx,从某个GridView的OnRowCommand开始:
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        int iIdx = Convert.ToInt32(e.CommandArgument);
        if (e.CommandName == "Print")
        {
            //Session["PrintFileID"] = GridView1.DataKeys[iIdx]["流水号"].ToString();
            string sLiuShuiID= GridView1.DataKeys[iIdx]["流水号"].ToString();
            Response.Write("<script>window.open('SendFileNew.aspx?id=" + sLiuShuiID + "')</script>");
        }
    }ShowFile.aspx的page_load事件里有:
            string sPath = dt.Rows[0]["附件"].ToString();  // 如果有附件
            if (sPath != "")
            {
                sPath = Server.MapPath("~") + sPath;
                Session["AttachmentPath"] = sPath;   // 暂用Session传
                Response.Write("<script>window.open('PrintAttachment.aspx')</script>");
            }PrintAttachment.aspx的page_load事件里有:
        string sPath = Session["AttachmentPath"].ToString();
        FileInfo DownloadFile = new FileInfo(sPath);
        if (DownloadFile.Exists)
        {
            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();
        }我选了一个有附件的文件,ShowFile.aspx都顺利弹出,同时应该会弹出PrintAttachment.aspx并出现"打开","保存"的那个对话框,有些电脑上可以正常显示PrintAttachment.aspx,但是很多电脑上PrintAttachment.aspx闪了一下就自己关了,估计是IE设置的问题,我调了半天也没弄好..本来以为是拦截弹出窗口的问题,但是一想:既然ShowFile.aspx可以弹出,为什么PrintAttachment.aspx不行..不是拦截窗口的问题..那是为什么呢?

解决方案 »

  1.   

    我的也老关,是看XXX网时,杀毒软件给关的,不知道您的是不。菜也要菜的有水平。我就是。
      

  2.   

    PrintAttachment.aspx.cs 中 你已经显示指定是下载文件:Response.ContentType = "application/octet-stream";
    Response.AppendHeader("Content-Disposition", "attachment;filename=" +应该弹出提示是否保存文件的窗口不对嘛?
      

  3.   

    Jinglecat(晓风残月 >> 问题需简洁,错误要详细) :
    有些电脑可以弹出提示是否保存文件的窗口,有些不弹出
      

  4.   

    yb00k() :
    我没设置时间,PrintAttachment.aspx在某些电脑上一直显示,但很多电脑上闪1-2秒,还没弹出提示是否保存文件的小窗口就关闭了我想应该不是弹出时间的问题,现在机房没VS,等下回去还是试试