【问题标题】:Problem with Crystal Report in ASP.NET - ExportToHttpResponseASP.NET 中水晶报表的问题 - ExportToHttpResponse
【发布时间】:2009-06-10 04:10:04
【问题描述】:

我正在使用代码从弹出窗口中导出 pdf 文件。

点击按钮

  function popupReport() 
    {
        var url = 'Report.aspx';
        window.open(url, 'winPopupReport', 'width=300,height=300,resizable=no,scrollbars=no,toolbar=no,directories=no,status=no,menubar=no,copyhistory=no');
        return false;
    }

在 Report.aspx.cs 中

 ReportDocument repDoc = ( ReportDocument ) System.Web.HttpContext.Current.Session["StudyReportCrystalDocument"];
        // Stop buffering the response
        Response.Buffer = false;
        // Clear the response content and headers
        Response.ClearContent();
        Response.ClearHeaders();
        try
        {
            repDoc.ExportToHttpResponse( CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, Response, true, "StudyReport" );
        }
        catch( Exception ex )
        {
        }

代码在 IE7 中运行良好。但在 IE6 中,弹出窗口没有关闭。为什么会这样?

【问题讨论】:

    标签: c# asp.net javascript crystal-reports export-to-pdf


    【解决方案1】:

    某些浏览器在某些情况下拒绝自动关闭网页。

    试试这个解决方法来关闭一个页面。

    在要关闭的页面中编写一个脚本,以打开另一个页面;在此示例中,脚本是在单击按钮后通过代码注入的,但如果需要,您可以直接用 HTML 编写。

       ClientScript.RegisterStartupScript(typeof(Page), "closePage", "window.open('Success.htm', '_self', null);", true);
    

    以这种方式创建 Success.htm 页面

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html>
     <head>
      <title></title>
      <script language="javascript" type="text/javascript">
       var redirectTimerId = 0;
       function closeWindow() {
          window.opener = top;
          redirectTimerId = window.setTimeout('redirect()', 2000);
          window.close();
      }
    
      function stopRedirect() {
         window.clearTimeout(redirectTimerId);
     }
    
      function redirect() {
         window.location = 'default.aspx';
     }
     </script>
    </head>
    <body onload="closeWindow()" onunload="stopRedirect()" style="">
       <center><h1>Please Wait...</h1></center>
    </body></html>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-09-22
      • 2010-12-15
      • 2020-05-18
      • 2010-10-24
      相关资源
      最近更新 更多