|
Working with a CrystalReportViewer with an AJAX UpdatePanel (ASP.NET) |
|
|
Written by: Evan Cummings
Working with a CrystalReportViewer with an AJAX UpdatePanel The CrystalReportViewer built into Visual Studio provides a simple and powerful way to display Crystal Reports. The Report Engine actively works behind the scenes to produce interactive reports appropriate for a web-based environment. One negative aspect of the CrystalReportViewer for ASP.NET is, however, that it requires a large amount of postbacks to do its work. This of course produces undesirable screen flicker. Anyone familiar with the recent trend in web development toward seamless transitions via AJAX will know that this technology has become tightly integrated into Visual Studio into its latest 2008 release, and is available as an extension to 2005. The logical idea is, of course, to throw AJAX into the mix to solve this problem. That problem is, it doesn't quite work as expected...
The CrystalReportViewer itself produces output that is not directly compatible with the ASP.NET AJAX UpdatePanel control. What you will run into quickly is that the Export and Print functionality provided by the CrystalReportViewer will not function - no print or export dialog boxes will apear to the user. The solution is more of a compromise - you cannot at the time being (until BusinessObjects produces an updated version) use the UpdatePanel to entirely suppress the CrystalReportViewer postbacks. What we can do is take advantage of what we can - and other actions are still perfectly valid in this situation.
To ensure the printing and exporting features of the CrystalReportViewer work while also being contained with an UpdatePanel, we need to add an additional trigger to specify the actions that need to take place.
... <Triggers> <asp:AsyncPostBackTrigger ControlID="ddlReports" EventName="SelectedIndexChanged" /> <asp:PostBackTrigger ControlID="crViewer" /> </Triggers> </asp:UpdatePanel>
The solution here allows for my DropDownList, ddlReports, to continue to function as intended - asychronously. The important difference is in the second trigger. My CrystalReportViewer, crViewer, requires its actions to be handled by the trigger as regular Postback events. We specificy this with the <asp:PostBackTrigger /> tag. This allows for the print and export functions to work within the CrystalReportViewer, while still maintaining some of the UpdatePanel's functionality.
The solution is not a perfect one - there will still be noticable flickers when working with the CrystalReportViewer, but we are minimizing this as much as possible. This brings our end user as close to the desktop experience as possible until the Control is able to support this functionality.
|
|
|
|
|
|