2

我的問題涉及嘗試在我的MVC應用程序中包含SSRS(SQL Server)報告。SSRS ReportViewer 2010 Iframe IE問題

我已經定居在,然後在具有一個iframe引用此頁面的WebForm MVC我View頁面具有ReportViewer控件一個WebForm的混合解決方案。棘手的部分是,由於將參數發佈到WebForm,因此iframe需要動態地填充報告而不是使用src。

它完美的Firefox和Chrome,IE卻拋出了「SYS是未定義」 JavaScript錯誤。

在iframe上使用src在IE中工作,但我找不到發佈參數的方法(由於可能的長度,不想使用類似/Report.aspx?param1=test的內容)。

它是一個ASP.NET MVC 2項目,.NET 4.0,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> 

而且代碼隱藏:

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

的解決問題的方法是使用表單元素後,然後填充的iframe,我還公佈了微軟連接錯誤作爲任何Microsoft AJAX的iframe導致JavaScript錯誤「SYS是未定義」,我試過1內腳本管理器和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