Can't find ReportViewer event for rendering complete

Andrew picture Andrew · Aug 25, 2011 · Viewed 12.5k times · Source

I'm trying to fire an event (to remove a custom progress/status indicator) when the ReportViewer control is finished rendering. I've explored the events for the ReportViewer control and I can't seem to find one that actually fires when the report is complete.

I'm using Visual Studio 2010 and ASP.NET 4.

Thanks for your help.

Answer

Matt picture Matt · Aug 6, 2013

I know this is old, but I wasn't satisfied with the polling approach. You can register a property change listener for changes to isLoading instead (as described here).

In summary, add a bit of javascript to the script manager e.g. in your form element:

<asp:ScriptManager ID="scriptManager" runat="server">
    <Scripts>
        <asp:ScriptReference Path="~/Reports/ReportViewer.js" />
    </Scripts>
</asp:ScriptManager>
<rsweb:ReportViewer ID="reportViewer" runat="server"/>

Then hook it up and add any client-side logic you need in ReportViewer.js:

Sys.Application.add_load(function () {
    $find("reportViewer").add_propertyChanged(viewerPropertyChanged);
});

function viewerPropertyChanged(sender, e) {
    if (e.get_propertyName() == "isLoading") {
        if ($find("reportViewer").get_isLoading()) {
            // Do something when loading starts
        }
        else {
            // Do something when loading stops
        }
    }
};