Print Page | Close Window

How to load Reports in a new web Window ?

Printed From: Crystal Reports Book
Category: Crystal Reports .NET 2003
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=1079
Printed Date: 28 Apr 2024 at 9:05am


Topic: How to load Reports in a new web Window ?
Posted By: louis
Subject: How to load Reports in a new web Window ?
Date Posted: 27 Jul 2007 at 4:28pm

I need to load every report in a new web window, not in the one where the custom parameters capture is done.


I'm basically having:

- A page .ASPX wich contain an .ASCX wich contain controls to capture the parameters to be passed to the report.
- An aditional page "Reports.ASPX" wich contain the "CrystalReportViewer" and who is in charge of showing every report in my CS web project.

I basically do:

- In the Clic() event of the button which is in charge of launching the report:

// To create a dataset to feed the report according to user request
 dsReport =  GetReportDataSet(GetCurrentUserParams());  
// To create the report object from the report class .rpt
 CurrentReport = new MyReportClass(); 
// To asociate the created DataSet to the report object
 CurrentReport.SetDataSource(dsReport); 
// To pass ussing Session the report to the report form which contain the ReportViewer
 Session.Add("CurrentReport",CurrentReport); 
// To transfer the control to the pages wich is in charge of showing the report
 Server.Transfer("Reports.aspx"); 

- In the Page_Load() event of the page "Reports.aspx"
 ReportClass CurrentReport = (MyReportClass)(Session["CurrentReport"]);
 CrystalReportViewer1.ReportSource = CurrentReport;
 CrystalReportViewer1.Visible = true;


So, everytime, each report is loaded in the same iexplorer window, having to deal with further navigation issues, for instance, loosing navigation history when I send output to PDF instead of previewing it.
Changing targets in the Crystal Report Viewer doesnt work for the first call.


Ok, thanks a lot in advance, I hope it's clear enough my current approach to be improved in such way I mentioned..

L.
 



Replies:
Posted By: BrianBischof
Date Posted: 27 Jul 2007 at 4:54pm
This is actually a complicated question and, ironically, it has nothing to do with Crystal Reports. You're basically asking how to use ASP.NET to open a new browser window with code. The fact that it is displaying a report is somewhat irrelevant. The problem comes in that ASP.NET doesn't have a way to open a new browser window via code. The only way to do it is to set the Target property of the button (not what you want), or use javascript to call the window.open() function. The javascript is the best route to take.

Unfortunately, the javascript method doesn't have anyway for you to pass the captured parameters to the new page. So what you need to do then is modify the javascript so that it builds a querystring using the parameter values and passes this to the Reports.aspx page.

Clearly, this is an advanced question and requires extensive knowledge of javascript. Depending upon you level of knowledge with javascript, you may or may not be able to pull this off.

Here is a link to open a new window in javascript, but it doesn't address the hardest part which is building that querystring.

http://aspalliance.com/525 - http://aspalliance.com/525


-------------
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>


Posted By: louis
Date Posted: 30 Jul 2007 at 5:45am
Yes, Brian thanks a lot.. I did deal with javascript before, I wanted to know whether there was a way to send the report in the server to a new page, using the viewer control probably...
 
Your answer is very clear anyway.
 
Regards and thaks again,
L.
 
 



Print Page | Close Window