How to Load Telerik Report in ASP.NET MVC Portable Area Project
We will here try to explain how one can implement “.trdx” extension Telerik report in ASP.NET MVC Portable Area application. The big question here was how we can create Telerik reports that are strongly typed and how to package them up. Since we would need controller actions for rendering or identifying Telerik report from assembly, it would be very difficult as when portable area project compiles it would generate a DLL. But we are using that DLL in another MVC application so we made a MVC project as a portable area with a use of MVCCONTRIB.
Following steps can help you to achieve it…
Step1: Create a Telerik report through Telerik report designer tool and save it within MVC application with .trdx extension.
Step2: Create _ARReportViewer.aspx view under view->shared folder in mvc application. Here as you can see we have picked .aspx view instead of razor view because we need to load Telerik report in TelerikReportViewer control inside MVC application. As TelerikReportViewer is a server control so we will have to set runat=”server” properties.
Steps 3: Create ARReportViewer.cshtml razor view under view->shared folder in mvc application and implement _ARReportViewer.aspx view as a partial view because when controller action is fired, it will find ARReportViewer view and load Telerik report.
Layout = null;
Step 4: Create same action method name as razor view name in appropriate controller. One More thing you should notice is that we have created new object of ReportBusinessModel and passed relevant entity object. – See more at: http://www.zealousys.com/blog/how-to-load-telerik-report-in-asp-net-mvc-portable-area-project/#sthash.f01vQ2tA.dpuf
Step 5: In ReportBusinessModel,we have defined the name, Title of the Telerik Report which is represented relevant entity object and displayed in a Telerik report. In above controller action method, you have seen that we have passed the result data as “performances” object to report.ReportInfo variable.
As you have observed ReportDocument in ReportBusinessModel, It is represents report data source. Here we have given the report assembly name as a report path.
public class ReportBusinessModel
private InstanceReportSource reportDocument;
private string reportName;
private readonly Dictionary<string, string> parameterList = new Dictionary<string, string>();