3
votes

I am using visual studio, ASP.NET. In my project i should use crystal report. unfortunately when i use crystal report in asp.net, the result is showing blank page.

My Html Code:

<head runat="server">
<title>Crystal Report From More Than One Table</title>
</head>
<body>
<form id="form1" runat="server">
<table cellpadding="10" cellspacing="10" width="70%" height="300px" align="center"
style="border: solid 2px gray;">
<tr>
<td align="center" style="background-color: SkyBlue;">
<span style="font-family: Times New Roman; font-size: 18pt; color: Green;">Customer
Product Order Detail Report</span>
</td>
</tr>
<tr>
<td align="center">
<asp:Panel ID="pnlReport" runat="server" Height="400px">
<CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="true" />
</asp:Panel>
</td>
</tr>
</table>
</form>
</body>

My CS Code (Code behind):

using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using CrystalDecisions.CrystalReports.Engine;

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
ReportDocument cryRpt = new ReportDocument();
cryRpt.Load(Server.MapPath("EmployeeCrystalReport.rpt"));
CrystalReportViewer1.ReportSource = cryRpt;
}
}
1

1 Answers

3
votes

That code is Correct but you should do two steps more:

1) Copy The folder with name crystalreportviewers13 on the C:\inetpub\wwwroot\aspnet_client\system_web\4_0_30319 and past it into project root folder as below on visual studio:

Right click on your project name, then select Open Folder On File Explorer

enter image description here

Paste the folder with name crystalreportviewers13on this address (Project Root)

enter image description here

After paste that, come back to your solution in visual studio, if the folder is hidden, you can do this:

Click Show All File button

enter image description here

then Right click on the folder with name crystalreportviewers13 which no color icon and choose Include In Project

enter image description here

2) Add this javascript on your html head page:

<script type="text/javascript" src="/crystalreportviewers13/js/crviewer/crv.js"></script> 

ENJOY!