Share via


Error Events

In previous versions of Crystal Reports for Visual Studio .NET, whenever you use the CrystalReportViewer control you have to trap for all possible thrown exceptions. Any exceptions that are left uncaught disrupt page processing and display an error.

To prevent disruptions and errors, a new event has been added to the CrystalReportViewer control, the Error event. When the Error event is used, the CrystalReportViewer control displays exception messages without disruption at the top of the CrystalReportViewer control.

To suppress the error page with the Error event method

To suppress the thrown exception, you call the Error event method and set ErrorEventArgs.Handled to True in the event handler.

  1. Add the Error event method to your code-behind class.

    Sub myCrystalReportViewer_Error(ByVal source As Object, ByVal e As
    CrystalDecisions.Web.ErrorEventArgs)
    End Sub
    
    void crystalReportViewer_Error(object source,
    CrystalDecisions.Web.ErrorEventArgs e)
    {
    }
    
  2. Set ErrorEventArgs.Handled to "True" in the event handler.

    e.Handled = True
    
    e.Handled = true;