2

내 문제는 내 MVC 응용 프로그램 내에 SSRS (SQL Server) 보고서를 포함시키는 것과 관련이 있습니다.SSRS ReportViewer 2010 Iframe IE 문제

ReportViewer 컨트롤이있는 WebForm과이 WebForm 페이지가있는 iframe 참조가있는 MVC View 페이지의 하이브리드 솔루션에 정착했습니다. 까다로운 부분은 WebForm에 매개 변수를 게시하기 때문에 src를 사용하는 대신 iframe을 동적으로 보고서로 채워야한다는 것입니다.

Firefox와 Chrome에서 완벽하게 작동하지만 IE에서 "Sys is Undefined"자바 스크립트 오류가 발생합니다.

iframe에서 src를 사용하면 IE에서 작동하지만 매개 변수 게시 방법을 찾을 수 없습니다 (가능한 길이 때문에 /Report.aspx?param1=test와 같은 것을 사용하고 싶지는 않습니다).

ASP.NET MVC 2 프로젝트, .NET 4, Visual Studio 2010 (Windows 7 x74). 그래서 여기

코드 내 웹 양식에서

(나는 누군가를 원하는 경우 VS2010 프로젝트 파일을 제공 할 수있다) :

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Report.aspx.cs" Inherits="SSRSMVC.Views.Home.Report" %> 

<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" 
    Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %> 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

<html xmlns="http://www.w3.org/1999/xhtml"> 
<body> 
    <form id="RSForm" runat="server"> 

    <asp:ScriptManager ID="ScriptManager" runat="server" EnablePartialRendering="true" ScriptMode="Release"> 
    </asp:ScriptManager> 

    <asp:UpdatePanel ID="ReportViewerUP" runat="server"> 
     <ContentTemplate> 
      <rsweb:ReportViewer ID="ReportViewer" runat="server" Width="100%" Height="380px" ProcessingMode="Local" 
      InteractivityPostBackMode="AlwaysAsynchronous" AsyncRendering="true"> 
       <LocalReport ReportPath="Models\\TestReport.rdlc"> 

       </LocalReport> 
      </rsweb:ReportViewer> 
     </ContentTemplate> 
    </asp:UpdatePanel> 

    </form> 
</body> 
</html> 

그리고 Codebehind가 : 마지막으로

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Web; 
using System.Web.UI; 
using System.Web.UI.WebControls; 
using Microsoft.Reporting.WebForms; 

namespace SSRSMVC.Views.Home 
{ 
    public partial class Report : System.Web.UI.Page 
    { 
     protected void Page_Load(object sender, EventArgs e) 
     { 
      if (!Page.IsPostBack) 
      { 
       string test = Request.Params["val1"]; 

       ReportViewer.LocalReport.DataSources.Add(new ReportDataSource("DataSet1", new SSRSMVC.Models.DataProvider().GetData())); 
      } 
     } 
    } 
} 

그리고 내 보기 페이지,

<script type="text/javascript"> 
    $(window).load(function() { 
     $.post('/Report.aspx', { val1: "Hello World" }, function (data) { 
      var rv_frame = document.getElementById('Frame1'); 
      rv_frame = (rv_frame.contentWindow) ? rv_frame.contentWindow : (rv_frame.contentDocument.document) ? rv_frame.contentDocument.document : rv_frame.contentDocument; 

      rv_frame.document.open(); 
      rv_frame.document.write(data); 
      rv_frame.document.close(); 
     }); 
    }); 
</script> 

답변

3

솔루션은 form 요소를 사용하여 iframe을 게시 한 다음 iframe을 채우는 것처럼 보입니다. iframe 내부에 Microsoft AJAX가 있기 때문에 JavaScript 오류 "sys is undefined"가 발생하므로 Microsoft Connect 버그도 게시했습니다. 스크립트 관리자와 1 개의 업데이트 패널에 오류가 발생했습니다. 해결 방법 코드

,

<div id="HiddenFormTarget" style="display:none;"></div> 

<iframe frameborder="0" id="Frame1" name="Frame1" style="width: 100%;height: 400px; overflow: hidden;"> 
</iframe> 

<script type="text/javascript"> 
    function ProcessReport() { 
     var form = $('<form method="post" target="Frame1" action="/Report.aspx"></form>'); 
     form.append('<input type="hidden" id="val1" name="val1" value="Hello World!!!" />'); 

     $("#HiddenFormTarget").append(form); 

     form.submit(); 

     $("#HiddenFormTarget").empty(); 
    } 

    $(window).load(function() { 
     ProcessReport(); 
    }); 

    $("H2").click(function() { ProcessReport(); }); 
</script> 

http://connect.microsoft.com/VisualStudio/feedback/details/561066/reportviewer-2010-iframe-internet-explorer