Andy0000
November 25th, 2007, 10:05 PM
Hi, I have developed a simple application in which on button click my asp page should print a already stored crystal report.
My code is as following..
Default.aspx
--------------------
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Style="z-index: 100;
left: 126px; position: absolute; top: 125px" Text="Show Report" Width="174px" />
</div>
</form>
</body>
</html>
---------------------------------------
Default.apsx.cs
------------------------------
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
//this is code where on the button click cy
protected void Button1_Click(object sender, EventArgs e)
{
ReportDocument rd = new ReportDocument();
rd.Load(@"C:\crystalset.rpt");//place where the reprot is saved
cv = new CrystalDecisions.Web.CrystalReportViewer();
crystalReportViewer1.ReportSource = rd;
}
}
On Button Click, nothing is happening. The page is reloaded but it doesnot show the crystal report.
Please point out what the mistake is.
My code is as following..
Default.aspx
--------------------
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Style="z-index: 100;
left: 126px; position: absolute; top: 125px" Text="Show Report" Width="174px" />
</div>
</form>
</body>
</html>
---------------------------------------
Default.apsx.cs
------------------------------
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
//this is code where on the button click cy
protected void Button1_Click(object sender, EventArgs e)
{
ReportDocument rd = new ReportDocument();
rd.Load(@"C:\crystalset.rpt");//place where the reprot is saved
cv = new CrystalDecisions.Web.CrystalReportViewer();
crystalReportViewer1.ReportSource = rd;
}
}
On Button Click, nothing is happening. The page is reloaded but it doesnot show the crystal report.
Please point out what the mistake is.