New to Telerik Reporting? Download free 30-day trial

Display custom error messages on web-based viewer

Environment

Product Progress® Telerik® Reporting
Report Viewer All web-based viewers

Description

How do I change the default error messages displayed by the HTML5-based Report Viewers with my custom ones? Example of such a message is the following:

Unable to get report parameters.
An error has occurred.
An error has occurred while resolving X data source: An error occurred while invoking data retrieval method.

Solution

Messages displayed by the HTML5-based Report Viewers are separated into two "categories". While the string "Unable to get report parameters." is a client-side message, the rest of the message is server-side one.

To change the client side text, use the approach demonstrated in the Localization article and change the corresponding value. However, this won't remove the server-side message. To change the entire message, use the following code snippet:

// Use this logic if you want to change the error message content. Based on the browser culture, you can change the text to different languages.
<script type="text/javascript">
    function onError(e, args) {
        if (args.indexOf("Unable to get report parameters.")) {
            $(".trv-pages-area .trv-error-pane .trv-error-message").html("Custom message here!")
        }
        ...
    }
</script>
In this article