Assembly References (From Visual studio2010 installation folder) :
Microsoft.ReportViewer.Common
Microsoft.ReportViewer.WebForms
Step 1 - Create a view called Report and bind it to strongly type ReportViewModel.
@model ReportViewModel
@{
ViewBag.Title = "Reports";
}
Reports: @Model.Title
height="965" width="100%" frameborder="0" marginwidth="0" marginheight="0" scrolling="yes">
Step 2 - Add a WebForm(ReportViewer.aspx) to your Web Project under a folder called Reports. It should have following html code in it.
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ReportViewer.aspx.cs" Inherits="Sample.Web.Reports.ReportViewer" %>
<%@ Register assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" namespace="Microsoft.Reporting.WebForms" tagprefix="rsweb" %>
Code behind
public partial class ReportViewer : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string ReportName = Request.QueryString["Name"];
if (ReportName != null)
{
string ReportServerURL = Request.QueryString["ServerURL"];
if (ReportServerURL == null)
ReportServerURL = @"http://localhost/reportserver";
rptViewer.ShowParameterPrompts = true;
rptViewer.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote;
rptViewer.ServerReport.ReportServerUrl = new Uri(ReportServerURL);
rptViewer.ServerReport.ReportPath = string.Format("/{0}", ReportName);
}
}
}