日期:2014-05-18  浏览次数:20654 次

window.open弹出的网页不到两秒自己关了?怎么办?
首先入口是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 ",   "attachm