ASP.NET MVC IFrame webform CrystalReportViewer

时间:2018-02-23 18:13:22

标签: c# asp.net-mvc iframe webforms

这个问题一直困扰着我几个小时。我有一个带有iframe的MVC视图(Report.cshtml)。我通过传入模型动态设置iframe的src。 我有一个webform(ReportViewer.aspx),里面有一个crystalreportviewer。我将reportname和parameters作为查询字符串的一部分传递给此webform。

ControllerCode:

image=cv2.cvtColor(image,cv2.COLOR_BGR2GRAY)

Report.cshtml:

        [HttpPost]
        [Authorize]
        public ActionResult ViewReport(ReportInfoViewModel _model)
        {
            string _parameterList = "";

            ReportViewerViewModel _rptObj = new ReportViewerViewModel();

            string[] _selected = {"0021", "2000", "0387"};                
                string subParam = "plazaparam=";
                subParam += String.Join(",", _selected);
                _parameterList = string.Concat(_parameterList, "@usrplazaparam=", String.Join(",", _selected));

string _reportSubPath = _model.report_path.Replace("\\", "/");
            string _reportPath = string.Concat("~/Content/Reports", _reportSubPath.Trim());


            string content = Url.Content(string.Format("~/CrystalReports/ReportViewer/ReportViewerForm.aspx?ReportName={0}&Parameters={1}", _reportPath, _parameterList));
            _rptObj.ReportViewerPath = content;
            return View("Report", _rptObj);
}

ReportViewer.aspx:

@{
    ViewBag.Title = "Report";    
    Layout = "~/Views/Shared/_rootLayout.cshtml";
}
@model CSC.ViewModels.ReportViewerViewModel


<iframe src="@Model.ReportViewerPath" style="width:100%; height:100%; border:none;"></iframe>

ReportViewer.aspx.cs:

<%@ Page Language="C#" AutoEventWireup="true"  MasterPageFile="~/Views/Shared/ReportSite.Master" CodeBehind="ReportViewerForm.aspx.cs" Inherits="CSC.CrystalReports.ReportViewer.ReportViewerForm" %>


<%@ Register Assembly="CrystalDecisions.Web, Version=13.0.3500.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" Namespace="CrystalDecisions.Web" TagPrefix="CR" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" HasCrystalLogo="False" AutoDataBind ="false" Height="100%"  EnableParameterPrompt="false" EnableDatabaseLogonPrompt="false" ToolPanelWidth="200px" 
        Width="100%" ToolPanelView="None"/>     
</asp:Content>

在Index.cshtml的页面上提交到ReportsController的ViewReport操作,我将动态构造的查询字符串“ReportViewer.aspx?ReportName = {reportName}&amp; Parameters = {parameterString}”传递给iframe的src。此代码应动态加载查询字符串中指定的报表(crystalreportviewer)并显示页面。发生的事情是在新页面中加载并显示相同的报告。我不确定我做错了什么。 如果有人能指出我正确的方向,我将不胜感激。

感谢您的帮助

NH

0 个答案:

没有答案