Click here to Skip to main content
15,915,603 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am using Crystal Reports 11.5 and I have built a webpage that contains the CrystalReportViewer control to display my report. I have set the print mode to "crViewer.PrintMode = PrintMode.Pdf" which automatically prints to PDF when I click the Print button on the Crystal Reports toolbar and IE asks where to save the PDF file.

My problem is the filename of the PDF is always defaulted "crViewer.pdf" which is the ID of the CrystalReportViewer control. I want to default the filename using a date and time stamp or some other known unique identifier, so the client can easily save them to their network folder.

So I have tried using the following code:-
crViewer.ID = "Report_" + Format(Now, "yyyyMMdd_HHmm")

Although this resolved my issue of defaulting the filename, it now causes another issue where the first time I use the Crystal Reports toolbar, say the "Next Page" button, nothing happens on the first click (but you see the page refresh). On the second attempt all buttons on the toolbar work continuously until I set the crViewer.ID to another filename.

I think whats happening is the CrystalReportViewer toolbar fails to find the control ID, as I have changed it for the filename. But after a one page refresh both the toolbar and control and synced again.

How do I perform a page refresh immediately after setting the crViewer.ID so that the Crystal Reports toolbar syncs with the CrystalReportViewer control ID?

Or is their a better way of defaulting the filename?

What I have tried:

So I have tried using the following code:-
crViewer.ID = "Report_" + Format(Now, "yyyyMMdd_HHmm")
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900