Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Nov 08, 2012 10:10 AM by DarrellNorton
Member
7 Points
75 Posts
Nov 08, 2012 06:10 AM|LINK
How to use Report Viewer control in MVC 4.
In View Page :
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <div> <rsweb:ReportViewer ID="rpt_CheckCashing" runat="server" Font-Names="Verdana" Width="100%" Height="800px" Font-Size="8pt" InteractiveDeviceInfos="(Collection)" ProcessingMode="Remote" WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt"> </rsweb:ReportViewer> </div> </ContentTemplate> </asp:UpdatePanel> </form> </asp:Content>
In Controller Page:
public ActionResult frmCheckCashing() { ReportViewer rpt_CheckCashing = new Microsoft.Reporting.WebForms.ReportViewer(); rpt_CheckCashing.ProcessingMode = ProcessingMode.Remote; rpt_CheckCashing.ServerReport.ReportServerUrl = new System.Uri(ConfigurationManager.AppSettings["ReportServerUrl"]); rpt_CheckCashing.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote; string strUserName = ConfigurationManager.AppSettings["UserName"].ToString(); string strPassword = ConfigurationManager.AppSettings["Password"].ToString(); string strDomain = ConfigurationManager.AppSettings["Domain"].ToString(); rpt_CheckCashing.ServerReport.ReportServerCredentials = new ReportCredentials(strUserName, strPassword, strDomain); rpt_CheckCashing.ServerReport.ReportPath = ConfigurationManager.AppSettings["CheckCashing"].ToString(); rpt_CheckCashing.ServerReport.Refresh(); rpt_CheckCashing.Visible = true; return View(); }
Is This a proper way to bind Report Viewer in mvc 4?
Iam getting Following Error
Microsoft JScript runtime error: Sys.ArgumentException: An element with id 'aspnetForm' could not be found. Parameter name: elementOrElementId
All-Star
86795 Points
9644 Posts
Moderator
MVP
Nov 08, 2012 10:10 AM|LINK
You can't use a ReportViewer control in an MVC view. You need to create a WebForms page outside of the MVC view with a link or redirect to the report.
See this article: http://www.code-magazine.com/article.aspx?quickid=1009061&page=1
Or these two blog posts:
http://blogs.msdn.com/b/sajoshi/archive/2010/06/16/asp-net-mvc-handling-ssrs-reports-with-reportviewer-part-i.aspx
http://blogs.msdn.com/b/sajoshi/archive/2010/06/16/asp-net-mvc-handling-ssrs-reports-with-reportviewer-part-ii-deployment-challenges.aspx
imranbasha
Member
7 Points
75 Posts
Problem with using Report Viewer in MVC view.
Nov 08, 2012 06:10 AM|LINK
How to use Report Viewer control in MVC 4.
In View Page :
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div>
<rsweb:ReportViewer ID="rpt_CheckCashing" runat="server" Font-Names="Verdana" Width="100%" Height="800px"
Font-Size="8pt" InteractiveDeviceInfos="(Collection)" ProcessingMode="Remote"
WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt">
</rsweb:ReportViewer>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</form>
</asp:Content>
In Controller Page:
public ActionResult frmCheckCashing()
{
ReportViewer rpt_CheckCashing = new Microsoft.Reporting.WebForms.ReportViewer();
rpt_CheckCashing.ProcessingMode = ProcessingMode.Remote;
rpt_CheckCashing.ServerReport.ReportServerUrl = new System.Uri(ConfigurationManager.AppSettings["ReportServerUrl"]);
rpt_CheckCashing.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote;
string strUserName = ConfigurationManager.AppSettings["UserName"].ToString();
string strPassword = ConfigurationManager.AppSettings["Password"].ToString();
string strDomain = ConfigurationManager.AppSettings["Domain"].ToString();
rpt_CheckCashing.ServerReport.ReportServerCredentials = new ReportCredentials(strUserName, strPassword, strDomain);
rpt_CheckCashing.ServerReport.ReportPath = ConfigurationManager.AppSettings["CheckCashing"].ToString();
rpt_CheckCashing.ServerReport.Refresh();
rpt_CheckCashing.Visible = true;
return View();
}
Is This a proper way to bind Report Viewer in mvc 4?
Iam getting Following Error
Microsoft JScript runtime error: Sys.ArgumentException: An element with id 'aspnetForm' could not be found.
Parameter name: elementOrElementId
DarrellNorto...
All-Star
86795 Points
9644 Posts
Moderator
MVP
Re: Problem with using Report Viewer in MVC view.
Nov 08, 2012 10:10 AM|LINK
You can't use a ReportViewer control in an MVC view. You need to create a WebForms page outside of the MVC view with a link or redirect to the report.
See this article: http://www.code-magazine.com/article.aspx?quickid=1009061&page=1
Or these two blog posts:
http://blogs.msdn.com/b/sajoshi/archive/2010/06/16/asp-net-mvc-handling-ssrs-reports-with-reportviewer-part-i.aspx
http://blogs.msdn.com/b/sajoshi/archive/2010/06/16/asp-net-mvc-handling-ssrs-reports-with-reportviewer-part-ii-deployment-challenges.aspx
Darrell Norton's Blog
Please click "Mark as Answer" if this helped you.