I'm trying to show reports with MVC3 and using razor. I found links on internet where you only download the reports without showing a preview: For example, but I would like to show a preview using the ReportViewer. Searching again i found this other example where a guy made a version for Mvc2 and VS2008 and it worked fine, but when i changed to Mvc3 i got a infinite loading bar showing the ReportViewer. Here is the ReportViewer for Mvc3.
Here are some files: Report.aspx
<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
Home Page
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<a href="../../Reports/Report.aspx" target="_blank">Print this...</a>
</asp:Content>
Index.aspx
<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
<%@ Register Assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
开发者_如何学C Home Page
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<a href="../../Reports/Report.aspx" target="_blank">Print this...</a>
</asp:Content>
Any help with Mvc3 ReportViewer.
Ps: Dont want use Telerik and others paying libraries.
Thanks in advanced.
ReportViewer is a server control and can't be added into a razor view. You can added a ReportViewer into any ASPX view page or view user control.
See my answer to this question for more details.
精彩评论