Skip to main content

WebDocumentViewerClientSideEventsBuilder.OnServerError(String) Method

Specifies the JavaScript function that handles the client-side OnServerError event.

Namespace: DevExpress.AspNetCore.Reporting.WebDocumentViewer

Assembly: DevExpress.AspNetCore.Reporting.v22.1.dll

NuGet Package: DevExpress.AspNetCore.Reporting


public WebDocumentViewerClientSideEventsBuilder OnServerError(
    string callback


Name Type Description
callback String

The name of a JavaScript function or entire JavaScript function code that runs when the OnServerError event occurs.


Type Description

A WebDocumentViewerClientSideEventsBuilder that can be used for method chaining.


The client-side OnServerError event is raised when a server-side error occurs. Handle this event to execute custom code when an Ajax request completes with an error.

The handler function receives two parameters. The first parameter is the client-side DocumentViewer that exposes the IPreviewModel interface (or the JSReportViewer object). The second is an object with the Error property, which contains information about an error:

The following code snippet logs error details and displays an alert box when a server error occurs:

<script type="text/javascript" id="script">
    function onServerError(s,e) {
        let actionKey = e.Error.getRequestDetails().actionKey;
        let error = e.Error.errorThrown;
        alert("Server error" + "\r\nAction: " + actionKey + "\r\nMessage: " + error);

    var viewerRender = Html.DevExpress().WebDocumentViewer("DocumentViewer")
        .ClientSideEvents(configure => configure.OnServerError("onServerError"))
See Also