.net, programming, sql server

JavaScript Reporting Services ReportViewer control error fix

I have been going back and forth banging my head against a wall trying to fix a JavaScript error that was happening on my Reporting Services ReportViewer control when the View Report button is clicked.  The error was a JavaScript error and seemed to be related to using something AJAX related on the same page as the ReportViewer control, but it took me a while to figure out what it was and fix it.  All of the problems I saw on the web related to using either an AJAX update panel or one of the extenders in the AJAX Control Toolkit.  Unfortunately for me I wasn’t using either one of them so trying to figure this one out was tricky.

The specific JavaScript error was:

Microsoft JScript runtime error: ‘this._postBackSettings.async’ is null or not an object

My page was setup where I had a master page with an AJAX menu on it (Radmenu to be specific).  In order to use the Radmenu you need a ScriptManager object.  Other than the menu, I didn’t have any AJAX related controls on either the master page or the content page.

What I eventually figured out was that my report pages (which use a base class) needed to disable partial rendering.  To do this, you must do it in your page’s init event.  If you do it after the init you’ll get an invalid operation exception.  Here’s the code in the base class (you can put this in your code behind if you’re not using a base class):

    Private Sub Page_Init1(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
        ' Make sure this page has a master page
        If Not IsNothing(Me.Master) Then
            Dim masterScriptManager As ScriptManager
            masterScriptManager = CType(Master.FindControl("MasterScriptManager"), ScriptManager)
            ' Make sure our master page has the script manager we're looking for
            If Not IsNothing(masterScriptManager) Then
                ' Turn off partial page postbacks for this page
                masterScriptManager.EnablePartialRendering = False
            End If
        End If
    End Sub

Just in case others stumble across this and are trying to solve their problem, here are some of the links I landed on when trying to solve the problem:

Tagged , , ,

12 thoughts on “JavaScript Reporting Services ReportViewer control error fix

  1. Wow, I’ve spent many, many hours on this one. Can’t thank you enough. I don’t know where to begin paying back people like you!

  2. I’m trying this. But now everytime I hit the “View Report” button (running in debug), I now get a javascript debug error that says Telerik is not defined!

    Any suggestions?

  3. Sounds like a problem with your Telerik Radcontrols. Maybe try taking them off if possible to debug the problem.

  4. Hello, I found this article while searching for help with JavaScript. I’ve recently changed browsers from Chrome to Internet Explorer 7. Now I seem to have a problem with loading JavaScript. Everytime I go on a website that needs Javascript, the page doesn’t load and I get a “runtime error javascript.JSException: Unknown name”. I cannot seem to find out how to fix the problem. Any help is greatly appreciated! Thanks

Leave a Reply

Your email address will not be published. Required fields are marked *