Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx thread: Crystal Reports - .NET Web App


Message #1 by "Stephen Woods" <SWoods@v...> on Thu, 27 Jun 2002 20:09:54 +1000
Hi,

What would the the best way to display a crystal report from a .Net Web App.

The best i could find was....

CrystalReportViewer1.ReportSource = "C:\Reportname.rpt"

Which displays it on the same form.

Is it possible to click the print button to open up a another window or at
least hide the previous form.

Any help would be appreciated.

Regards,
Stephen


Message #2 by "Stephen w" <swoods@v...> on Fri, 28 Jun 2002 02:01:24
Hi,

What would the the best way to display a crystal report from a .Net Web 
App.

The best i could find was....

CrystalReportViewer1.ReportSource = "C:\Reportname.rpt"

Which displays it on the same form.

Is it possible to click the print button to open up a another window or at 
least hide the previous form.

Any help would be appreciated.

Regards,
Stephen
Message #3 by Williams Kyle M Contr OC-ALC/LIP <Kyle.Williams@t...> on Fri, 28 Jun 2002 06:21:27 -0500
You can redirect your response to a classic ASP page and from there use Java
Scripting to open a new window for the crystal report and then redirect the
existing window back to whatever you want. Try using this. The first ASP
Page is your classic asp page that will accept the values from your query
string and then open a new window and redirect your current window. The
second ASP Page opens accepts your parameters for your form(if you have any)
and then opens the form. 

First Page:
<HTML>			
	<HEAD>

		<title>Web App Title</title>
			<%			

				Dim Leng 
				Dim sWorkLoad
				Dim sTypeAsst
				Dim sSortItem
				Dim sStartDate
				Dim sEndDate
				sWorkLoad = request.QueryString("WorkLoad")
				sTypeAsst = request.QueryString("TypeAsst")
				sSortItem = request.QueryString("OrderBy")
				sStartDate 
request.QueryString("StartDate")
				sEndDate = request.QueryString("EndDate")

				%>
				<script language="JavaScript">
		function Init() { 
		
		window.open('NewPageName.asp?WorkLoad=' +
self.frmHeader.txtWorkLoad.value + '&TypeAsst=' +
self.frmHeader.txtTypeAsst.value + '&SortItem=' +
self.frmHeader.txtSortItem.value + '&StartDate=' +
self.frmHeader.txtStartDate.value + '&EndDate=' +
self.frmHeader.txtEndDate.value, Help','toolbar=no,width
900,height=700,resizable=0'); 
		window.self.location.href='../default.aspx';
		} </script>
	</HEAD>
	<body onload="Init()">
		<form id="Form1" name="frmHeader" method="post"
runat="server">
			<INPUT id="txtWorkLoad" type="text" name="Text2"
value=<%=sWorkLoad%>> 
			<INPUT id="txtTypeAsst" type="text" name="Text3"
value=<%=sTypeAsst%>> 
			<INPUT id="txtSortItem" type="text" name="Text4"
value=<%=sSortItem%>> 
			<INPUT id="txtStartDate" type="text" name="Text3"
value=<%=sStartDate%>> 
			<INPUT id="txtEndDate" type="text" name="Text4"
value=<%=sEndDate%>> 
			
	</body>
</HTML>


Second Page the opens the actual report:

<HTML>
	<HEAD>
		<title>WebPage Title</title>
<%
Dim sWorkLoad
sWorkLoad=Request.QueryString("Workload")
%>
	</HEAD>
	<body bgColor="#ffffff">
		<%
						
		reportname = "ReportName.rpt"%>
		<!-- #include file="AlwaysRequiredSteps.asp" -->
		<% 
			session("oRpt").MorePrintEngineErrorMessages = True
			session("oRpt").EnableParameterPrompting = True

			set crtable 
session("oRpt").Database.Tables.Item(1)
			crtable.SetLogonInfo WebAppName, DatabaseName,
cstr(UserID),cstr(Password)

			set StoredProcParamCollection 
Session("oRpt").ParameterFields

			Set ThisParam = StoredProcParamCollection.item(1)
			ThisParam.SetCurrentValue cstr(strUsername), 12

			Set ThisParam2 = StoredProcParamCollection.item(2)
			ThisParam2.SetCurrentValue cint(sWorkLoad), 7
			
		%>
		<!-- #include file="MoreRequiredSteps.asp" -->
		<!-- #include file="SmartViewerActiveX.asp" -->
	</body>
</HTML>



Hope this helps

Kyle


-----Original Message-----
From: Stephen w [mailto:swoods@v...]
Sent: Thursday, June 27, 2002 9:01 PM
To: ASP+
Subject: [aspx] Crystal Reports - .NET Web App


Hi,

What would the the best way to display a crystal report from a .Net Web 
App.

The best i could find was....

CrystalReportViewer1.ReportSource = "C:\Reportname.rpt"

Which displays it on the same form.

Is it possible to click the print button to open up a another window or at 
least hide the previous form.

Any help would be appreciated.

Regards,
Stephen
Message #4 by "Lewis Bass" <lewis@t...> on Fri, 28 Jun 2002 10:35:29 -0600
We use Adobe to view the report. This is so that the print button in acrobat
can be used (if desired by the user)
The crystal report viewer does not have a print button when used on the web.

Getting the report to pdf format is a bit tricky however. You have to export
it to a FTP site, or open up the permissions on
you web site to an unacceptable level. Here is some sample code that passes
paramaters to the report. I wish that there was a better way
to pass the report paramaters - one similiar to that used by the Crystal Web
Browser, but I can not find one. If you do let me know


GOOD LUCK!
Lewis Bass




Dim crReport As New SalesReport()

Dim crExportOptions As ExportOptions

Dim crDiskFileDestinationOptions As DiskFileDestinationOptions

Dim OutputPath As String

Dim RedirectPath As String

crDiskFileDestinationOptions = New DiskFileDestinationOptions()

' use the actual real operating system file name for the output file name

OutputPath = "D:\FtpSites\Transda\" & Session.SessionID & ".pdf"

' use the ftp path name for viewing

RedirectPath = "ftp://185.1.3.4/" & Session.SessionID & ".pdf"

crDiskFileDestinationOptions.DiskFileName = OutputPath

crExportOptions = crReport.ExportOptions

With crExportOptions

    .ExportDestinationType = ExportDestinationType.DiskFile

    .ExportFormatType = ExportFormatType.PortableDocFormat

    .DestinationOptions = crDiskFileDestinationOptions

End With

' setup the report paramaters

crReport.RecordSelectionFormula = "{sale.sonum} >= 1011415 and {sale.sonum}
<= 1011419"

' export the report

crReport.Export()

' redirect to the ftp web site

Response.Redirect(RedirectPath)





----- Original Message -----
From: "Stephen w" <swoods@v...>
To: "ASP+" <aspx@p...>
Sent: Friday, June 28, 2002 2:01 AM
Subject: [aspx] Crystal Reports - .NET Web App


> Hi,
>
> What would the the best way to display a crystal report from a .Net Web
> App.
>
> The best i could find was....
>
> CrystalReportViewer1.ReportSource = "C:\Reportname.rpt"
>
> Which displays it on the same form.
>
> Is it possible to click the print button to open up a another window or at
> least hide the previous form.
>
> Any help would be appreciated.
>
> Regards,
> Stephen
>


  Return to Index