ASP.NET MVC VS2010 Crystal Reports Beta 2 无法打印、导出、缩放或更改页面 [英] ASP.NET MVC VS2010 Crystal Reports Beta 2 Can't Print, Export, Zoom, or Change Pages

查看:18
本文介绍了ASP.NET MVC VS2010 Crystal Reports Beta 2 无法打印、导出、缩放或更改页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚升级到 Crystal Reports for Visual Studio 2010 的 beta 2,在 ASP.NET MVC 应用程序中使用 Web 控件时,我无法打印、导出、缩放或更改页面.

I just upgraded to the beta 2 of Crystal Reports for Visual Studio 2010 and I'm not able to print, export, zoom, or change pages while using the web control in an ASP.NET MVC application.

我可以让报告在网页上正常运行和显示.所有按钮都有图像,并且报告数据看起来与页面上应有的完全一样.

I can get the report to run and display just fine on the webpage. All of the buttons have images, and the report data looks exactly as it should on the page.

在 VS2010 中查看 .rpt 时,我可以单击报告预览"并让报告运行并打印、导出、缩放等...这似乎使用 Windows 控件来呈现报告而不是 Web控制.因此我相信我的报告文件本身是有效的.

In VS2010 while looking at the .rpt I can click 'Report Preview' and get the report to run and print, export, zoom, etc...this appears to use the windows control to render the report and not the web control. Thus I believe my report file itself is valid.

在网页上查看 Crystal Reports Viewer 中的报告时,当我尝试每个按钮时,我会获得不同的功能:

While on the webpage viewing the report in the Crystal Reports Viewer I get different functionality when I try each of the buttons:

  • 打印:单击打印按钮一次,报表返回网络服务器,重新运行报表,然后返回网页,不执行任何操作.再次按下它,它会打开一个新标签,在这个新标签中包含相同的报告.
  • 导出:导出打开对话框,询问我要导出到哪种格式.一旦我做出选择,它就会执行与 print 相同的功能,然后转到后端,然后什么也没有.再次按导出会打开一个新选项卡,其中包含报告.
  • 缩放/更改页面 - 这两个选项都会弹出一个对话框、一个微调器,然后冻结页面.

无论我使用哪种浏览器(IE、Chrome、Mozilla),我都会得到相同的行为,并且所有浏览器都关闭了弹出窗口阻止程序.

I get the same behavior regardless of which browser I use, (IE, Chrome, Mozilla), and all of the browsers have pop-up blocker turned off.

使用 Chrome 的开发者工具时,我确实在页面上遇到了两个错误:

Using Chrome's developer tools I do get two errors on the page:

  • JobHistory:59[导致此错误的 HTML 是由脚本生成的.] 遇到不匹配的情况.忽略标签.
  • JobHistory:59[导致此错误的 HTML 是由脚本生成的.] 遇到不匹配的情况.忽略标签.

我尝试过的其他项目:

  • 删除了所有以前版本的 Crystal Reports
  • 卸载并重新安装 Crystal Reports Beta 2
  • 从头开始重新启动我的解决方案,最初它是 2008 年的升级.
  • Cross 在 Crystal Reports beta 2 论坛上发布了这个问题

非常感谢您对我可以尝试的事情的任何想法或建议.

Any thoughts or suggestions on things I could try are greatly appreciated.

推荐答案

Crystal Report 的 Report Viewer 控件是一个服务器端控件,因此,当它是 MVC 视图页面的一部分时,它不能正常工作.因此,当我尝试打印或导出导致回发时,我会不断地看到页面刷新,而不是打印或导出.

Crystal Report's Report Viewer control is a server side control, as such, it doesn't function properly when part of an MVC view page. Hence, when I tried to print or export, causing a post back, I would continually see a page refresh, instead of printing or exporting.

这种行为不同于我在 Visual Studio 2008 中使用的 ASP.NET MVC 版本 1 和随 VS2008 一起提供的 Crystal Reports 版本.在 VS2010 和 Crystal Reports 2010 目前的 beta 版本中,报表查看器控件需要位于普通的旧 aspx 页面上,而不是 MVC 视图页面的一部分.

This behavior is different from ASP.NET MVC version 1 that I used with Visual Studio 2008 and the version of Crystal Reports that came with VS2008. In VS2010 and, as of now beta of, Crystal Reports 2010, the Report Viewer control needs to be on a plain old aspx page and not part of an MVC view page.

为了实现这一点,我采取了以下步骤,其中许多步骤与我之前在相关问题中使用的步骤相同,但我已针对 VS2010 和 CrystalReports 2010 中看到的新行为对它们进行了调整:StackOverflow.com:使用 MVC 框架破坏的 CrystalReportViewer 按钮

To accomplish this I took the following steps, many of these steps are the sames ones I used before in a related question, but I have tweaked them for the new behavior seen in VS2010 and CrystalReports 2010: StackOverflow.com: CrystalReportViewer Buttons Broken using MVC Framework

  • 在我的控制器中,我调用了对我的模型的正确调用来获取我的报告数据,

列表<JobSummaryBody>body = model.GetJobSummaryBody(jobId, startDate, endDate);

  • 接下来,我为报表本身创建一个变量,在本例中:

JobSummaryByDate 摘要 = new JobSummaryByDate();

注意:JobSummaryByDate 是我在设计报表时由 Crystal Reports 创建的数据类型,它是代码生成的.将其视为您设计的报告将需要的所有数据.

Note: JobSummaryByDate is a data type created by Crystal Reports when I design my report, it is code generated. Think of it as all of the data that your designed report is going to need.

  • 接下来我为刚刚创建的报表设置数据源,即行数据

summary.SetDataSource(body);

  • 最后,我将我的报表数据存储在 Session 中,然后对包含 Crystal Reports Viewer 的我的 aspx 页面执行 Response.Redirect

Session["ReportData"] = 摘要;Response.Redirect("~/CrystalReports/JobSummaryByDateView.aspx");

注意:我在我的项目中创建了一个名为CrystalReports"的新顶级文件夹,该文件夹实际上可以通过 URL 导航到.

Note: I have created a new top level folder in my project called "CrystalReports", the folder can actually be navigated to by URL.

  • JobSummaryByDateView.asp 的源页面非常简洁,添加水晶报表查看器,在这种情况下我给它一个报表查看器的 ID:

  • The source page for JobSummaryByDateView.asp is very striaght forward, add the Crystal Report Viewer, in this case I gave it an ID of Report Viewer:

<CR:CrystalReportViewer ID="ReportViewer" runat="server" AutoDataBind="true"EnableDatabaseLogonPrompt="False" EnableParameterPrompt="False"ToolPanelView="None" HasDrilldownTabs="False" HasDrillUpButton="False"HasSearchButton="False" HasToggleGroupTreeButton="False"HasToggleParameterPanelButton="False" ReuseParameterValuesOnRefresh="True"/>

protected void Page_Init(object sender, EventArgs e){ReportViewer.ReportSource = Session["ReportData"];}

这篇关于ASP.NET MVC VS2010 Crystal Reports Beta 2 无法打印、导出、缩放或更改页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆