locked
ReportViewer inside UpdatePanel not working RRS feed

  • Question

  • User2146958572 posted

    Has anyone been able to get the ReportViewer to work correctly inside an UpdatePanel?

    For me the report renders fine on the initial whole-page refresh, but when I click the next page button the next page renders but doesn't allow me to navigate through the pages anymore. The toolbar says "(blank) of 0" pages and the arrow toolbar buttons for navigating between pages are all disabled.

    Friday, November 10, 2006 4:16 PM

Answers

  • User-690975684 posted

    The main problem is using Page.ClientScript for script and arrays registration. In CTP ("Atlas") it was overrided but in final version already not. I'ts related to all 3rd party controls that are not AJAX ASP.NET oriented. So I've fixed the problem with reflection using.

    For example I have a user control that contains UpdatePanel with ReportViewer inside.

    The main problem is using Page.ClientScript for script and arrays registration. In CTP ("Atlas") it was overrided but in final version already not. I'ts related to all 3rd party controls that are not AJAX ASP.NET oriented. So I've fixed the problem with reflection using.

    For example I have a user control that contains UpdatePanel with ReportViewer inside. ReportViewer makes registration for two script blocks, one of them with name that contains prefix "SqlReportingServicesActionScript". So I just make a search for these scripts in _registeredClientScriptBlocks collection and make registration again, but with ScriptManager.RegisterClientScriptBlock call.

    Also I should use the PreRenderComplete of Page because in OnPreRender of user control these scripts are not registered yet. 

    protected override void OnInit(EventArgs e)
    
    {
    
    base.OnInit(e);
    
    this.Page.PreRenderComplete += new EventHandler(OnPagePreRender);
    
    }
    
    protected void OnPagePreRender(object sender, EventArgs eventArgs)
    
    {
    
    
    
    System.Collections.Specialized.ListDictionary scripts = this.Page.ClientScript.GetType().GetField("_registeredClientScriptBlocks", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).GetValue(this.Page.ClientScript) as System.Collections.Specialized.ListDictionary;
    
    foreach (object key in scripts.Keys)
    
    {
    
    Type type = key.GetType().GetField("_type", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).GetValue(key) as Type;
    
    string registeredKey = key.GetType().GetField("_key", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).GetValue(key) as string;
    
    if (Type.Equals(type, ReportViewer.GetType()) && 
    
    (String.Equals(registeredKey, String.Concat("SqlReportingServicesActionScript", ReportViewer.ClientID)) || String.Equals(registeredKey, ReportViewer.ClientID)))
    
    {
    
    ScriptManager.RegisterClientScriptBlock(this.Page, type, registeredKey, scripts[key] as string, true);
    
    }
    
    }
    
    }
    
     

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, March 27, 2007 4:04 AM

All replies

  • User2146958572 posted
    I'm still looking for reponses on this one. Has anyone else tried this?
    Monday, November 13, 2006 11:08 AM
  • User1618900539 posted

    Terry, I tried to use a ReportViewer within an Update Panel, but I had many weird results, including what you are describing. I tried a lot of combinations of triggers, async rendering, etc, with no luck.

    I looked for documentation, but I couldn't find any official comment on AJAX with Reports, so finally I decided to drop AJAX for Reports.

    Well, not very useful, but at least you know that somebody else tried it! :)  

     

    Cheers,

    Juan 

    Monday, November 13, 2006 3:34 PM
  • User2146958572 posted

    Thanks Juan,

    That confirms that the two just don't work together. Hopefully someone from the Atlas team will read this and try to get the problems resolved, but I'm not holding my breath!

     Terry

    Monday, November 13, 2006 3:48 PM
  • User1618900539 posted

    Terry, just a thought,

    I found that if you use your own controls to set the Reports parameters you don't need AJAX for Reports, the ReportViewer control will still be refreshing itself, but you can encapsulate use UpdatePanels with all the other controls in the page, giving it the same user experience than if it had AJAX.

    Are you sure you need to contain your ReportViewer into an UpdatePanel?

     

    Monday, November 13, 2006 3:55 PM
  • User2146958572 posted

    Thanks for the suggestion, but we use various functionality of the built-in toolbar on the ReportViewer control. You're right that I could replicate all of that with my own toolbar, but I don't have time and would rather use it as-is without Ajax than go to that trouble. I've posted this issue on the MSDN Reporting Services forum, so maybe someone from the RS team will see it as well.

     Thanks

    Monday, November 13, 2006 4:11 PM
  • User2146958572 posted

    Microsoft -- (if anyone's listening) -- will this be fixed in the next release?

    Thursday, November 16, 2006 4:24 PM
  • User-690975684 posted

    The main problem is using Page.ClientScript for script and arrays registration. In CTP ("Atlas") it was overrided but in final version already not. I'ts related to all 3rd party controls that are not AJAX ASP.NET oriented. So I've fixed the problem with reflection using.

    For example I have a user control that contains UpdatePanel with ReportViewer inside.

    The main problem is using Page.ClientScript for script and arrays registration. In CTP ("Atlas") it was overrided but in final version already not. I'ts related to all 3rd party controls that are not AJAX ASP.NET oriented. So I've fixed the problem with reflection using.

    For example I have a user control that contains UpdatePanel with ReportViewer inside. ReportViewer makes registration for two script blocks, one of them with name that contains prefix "SqlReportingServicesActionScript". So I just make a search for these scripts in _registeredClientScriptBlocks collection and make registration again, but with ScriptManager.RegisterClientScriptBlock call.

    Also I should use the PreRenderComplete of Page because in OnPreRender of user control these scripts are not registered yet. 

    protected override void OnInit(EventArgs e)
    
    {
    
    base.OnInit(e);
    
    this.Page.PreRenderComplete += new EventHandler(OnPagePreRender);
    
    }
    
    protected void OnPagePreRender(object sender, EventArgs eventArgs)
    
    {
    
    
    
    System.Collections.Specialized.ListDictionary scripts = this.Page.ClientScript.GetType().GetField("_registeredClientScriptBlocks", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).GetValue(this.Page.ClientScript) as System.Collections.Specialized.ListDictionary;
    
    foreach (object key in scripts.Keys)
    
    {
    
    Type type = key.GetType().GetField("_type", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).GetValue(key) as Type;
    
    string registeredKey = key.GetType().GetField("_key", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).GetValue(key) as string;
    
    if (Type.Equals(type, ReportViewer.GetType()) && 
    
    (String.Equals(registeredKey, String.Concat("SqlReportingServicesActionScript", ReportViewer.ClientID)) || String.Equals(registeredKey, ReportViewer.ClientID)))
    
    {
    
    ScriptManager.RegisterClientScriptBlock(this.Page, type, registeredKey, scripts[key] as string, true);
    
    }
    
    }
    
    }
    
     

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, March 27, 2007 4:04 AM
  • User-571342813 posted

    Terry, just a thought,

    I found that if you use your own controls to set the Reports parameters you don't need AJAX for Reports, the ReportViewer control will still be refreshing itself, but you can encapsulate use UpdatePanels with all the other controls in the page, giving it the same user experience than if it had AJAX.

    Are you sure you need to contain your ReportViewer into an UpdatePanel?

     

    I can't make this method work: I have an update panel and a report viewer (not in the update panel) on the same page.  The first async postback in the update panel works fine, but any subsequent postbacks throw an index out of range error.  The entire setup runs without error when either a) the update panel is removed from the page entirely or b) the report viewer is removed from the page.  The first case leaves a lot of page refreshing while the user sets the parameters; the second case defeats the purpose of the page.

     I've spent two days looking for a workaround for this - if anyone is still following this thread, I'd love to hear if there is any solution/workaround, or even if anyone else is having the same problem.

    Thursday, November 15, 2007 12:30 PM
  • User1965044966 posted

    I cannot get it work with ReportViewer.AsyncRendering="false", can anyone help me solve script error? This is my current code base on Yarick's:

        protected void Page_PreRenderComplete(object sender, EventArgs e)
        {
            ListDictionary scripts = ClientScript.GetType().GetField("_registeredClientScriptBlocks", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(ClientScript) as ListDictionary;

            foreach (object key in scripts.Keys)
            {
                Type type = key.GetType().GetField("_type", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(key) as Type;
                if (type.Namespace.StartsWith("Microsoft.Reporting.WebForms"))
                {
                    string registeredKey = key.GetType().GetField("_key", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(key) as string;
                    ToolkitScriptManager.RegisterClientScriptBlock(Page, type, registeredKey, scripts[key] as string, true);
                }
            }

    Tuesday, December 4, 2007 4:42 AM
  • User1161544444 posted

    Hi Yarick,

    Thanks a lot for the code! It works perfectly fine.

    We are using an Update Panel in a Web part. This update panel contains a ReportViewer control, it worked fine unless the Report Viewer control was hidden and displayed back.

    I spent a long time finding a resolution and was quited disappointed looking at messages stating that it doesnt work in this version of report viewer, but your solution worked in this specific case.

    Warm Regards,

    Manu

     

     

     

     

    Wednesday, April 16, 2008 3:16 AM
  • User1854312045 posted

    Hi Manu,

    I am also making a ReportViewer get working within UpdatePanel.
    It works fine in IE but firefox throws  following error
    -------
    uncaught exception: [Exception... "Component returned failure code: 0x80004003 (NS_ERROR_INVALID_POINTER) [nsIDOMLocation.toString]" nsresult: "0x80004003 (NS_ERROR_INVALID_POINTER)" location: "JS frame ::
    -----------

    Did anyone had such issue with firefox ? Also is it possible to post a sample code that worked for you ?
    -Thx

    Tuesday, April 29, 2008 3:11 AM
  • User1335300232 posted

     Thanks a lot for the code! it very good.

     

    Friday, March 6, 2009 11:45 AM
  • User1144777462 posted

    The code didnt work me. As soon as I move the scroll bar and click any control a javascript error message pops up.

    Friday, August 21, 2009 6:22 AM
  • User1817246121 posted

    Anyone know if the latest release of the Ajax Control Toolkit resolves this issue?  I can't seem to find any concrete information on what bug fixes have been addressed, just that it includes "significant bug fixes."

    Thursday, October 1, 2009 7:40 PM
  • User-1205481908 posted

    The weird thing for me is that the reportviewer and updatepanel work great (even without Yarick's code) in Firefox, but not in ie8 or ie7!

    I keep getting:


    Message: 'parent.document.getElementById(...).ClientController' is null or not an object
    Line: 5
    Char: 1


    Message: 'this.m_clientController' is null or not an object
    Line: 317
    Char: 5

     need more testing to get this one figured out.

     

    Monday, March 15, 2010 7:50 PM
  • User-1630344595 posted

    i fixed this bug by using 

    Microsoft Report Viewer 2010 Redistributable Package

    from :

    http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=a941c6b2-64dd-4d03-9ca7-4017a0d164fd


    then change web config as following


    from 

                <assemblies>
                    <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
                    <add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
                    <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
                    <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
                    <add assembly="Microsoft.ReportViewer.WebForms, Version=9.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
                    <add assembly="Microsoft.ReportViewer.Common, Version=9.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
                </assemblies>

                <assemblies>

                    <add assembly="Microsoft.ReportViewer.WebForms, Version=9.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />

                    <add assembly="Microsoft.ReportViewer.Common, Version=9.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />

                </assemblies>


    to

          <assemblies>

            <add assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />

            <add assembly="Microsoft.ReportViewer.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />

          </assemblies>

    add this to runtime 

    <runtime>

        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">

          <dependentAssembly>

            <assemblyIdentity name="Microsoft.ReportViewer.WebForms" publicKeyToken="b03f5f7f11d50a3a"/>

            <bindingRedirect oldVersion="9.0.0.0-9.1.0.0" newVersion="10.0.0.0"/>

          </dependentAssembly>

        </assemblyBinding>

      </runtime>

    Tuesday, April 20, 2010 4:30 AM
  • Tuesday, April 20, 2010 11:19 PM
  • User1830759377 posted

    Hi !

    This is not the best solution, but works with a litle compromise.

    ScriptManager1.RegisterPostBackControl((Control) ReportViewer1);

    DBT.

    Monday, September 20, 2010 7:49 AM
  • User-37337701 posted

    My report is generated after startDate and EndDate is selected and button is clicked. So it is not visible initially.

    The button is placed outside the update panel and added as asyncpostbacktrigger to the update panel containing reporviewer.

    And works completely fine.

        <asp:Button ID="Button1" runat="server" OnClick="ViewReport_Clicked" Text="View Report"

                        SkinID="ButtonA" />

     

                   <asp:UpdatePanel ID="TFD_UP" runat="server">

                   <ContentTemplate>

                    <rsweb:ReportViewer ID="ReportViewer1" runat="server" SizeToReportContent="True"

                        Height="202px" Width="935px" Font-Names="Verdana" Font-Size="8pt" InteractiveDeviceInfos="(Collection)"

                        WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt" Visible="false">

                        <LocalReport ReportPath="Reports\Report4.rdlc">

                            <DataSources>

                                <rsweb:ReportDataSource DataSourceId="SqlDataSourceArchiSpecs" Name="Proc_TechFilesDownloadsDataSetParent" />

                            </DataSources>

                        </LocalReport>

                    </rsweb:ReportViewer>

                    <asp:SqlDataSource ID="SqlDataSourceArchiSpecs" runat="server" ConnectionString="<%$ ConnectionStrings:ArchiSpecsDBConnectionString %>"

                        SelectCommand="PROC_TECHNICALFILES_DOWNLOAD_DETAILS" SelectCommandType="StoredProcedure">

                        <SelectParameters>

                            <asp:Parameter Name="supId" Type="Int32" />

                            <asp:Parameter Name="startDate" Type="DateTime" />

                            <asp:Parameter Name="endDate" Type="DateTime" />

                        </SelectParameters>

                    </asp:SqlDataSource>

                    </ContentTemplate>

                    <Triggers>

                        <asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" />

                    </Triggers>

                    </asp:UpdatePanel>

    Tuesday, March 29, 2011 2:40 AM
  • User1093107942 posted

    Hello all. I was having the same problem.

    For some reason, issuing a .Reset() in every page_load to the reportviewer control does the trick.

    I am using two reportviewer controls, in updatepannel, using assyncpostback and partial rendering.

    Here's some snipets:

    Register the ajax script manager:

    <ajaxToolkit:ToolkitScriptManager ID="ScriptManager1" runat="server" ScriptMode="Inherit" OnAsyncPostBackError="ScriptManager1_AsyncPostBackError">

    (...)

    The update pannel with the reportviewer control (i have it inside a customcontrol to solve a script problem in chrome)

    <asp:UpdatePanel ID="rsUpdPannel" runat="server" UpdateMode="Conditional">
    <ContentTemplate>
    <asp:PlaceHolder runat="server" ID="reportPlaceHolder">
    <asp:Label ID='errlbl' runat="server" CssClass='error' meta:resourcekey="errlblResource1" />
    <rsweb:CustomReportViewer ID='ReportViewer1' runat="server"

    (...)

    it's triggered from another control

    <Triggers>
    <asp:AsyncPostBackTrigger ControlID="servicosDataLst" EventName="SelectedIndexChanged" />
    </Triggers>

    in the conde behind page_load

    protected void Page_Load(object sender, EventArgs e)
    {
       ReportViewer1.Reset(); 

    It works for me.

    I got to this "design" trying to sort a problem with setting the reportviewer currentpage because i had seen somewhere that you should do it in order to use it.

    Still happening the two javascript errors on each ajax callback 

    function OnLoadReport(reloadDocMap)
    {
    this.m_clientController.OnReportLoaded(this, reloadDocMap);
    <frame src="javascript:&#39;&#39;" id="docmap" name="docmap" frameborder="0" /><frame src="/asdasdasd" id="report" name="report" frameborder="0" noresize="true" onload="parent.document.getElementById(&#39;MainContent_ReportViewer1&#39;).ClientController.OnReportFrameLoaded();" />

    but the control keeps working.
    I had a problem showing reports in ie after callback because of the two previous errors. 
    I had to use javascript to make the report's iframe visible.

    $("#ReportFrameMainContent_ReportViewer1").load(function () {
    document.getElementById("ReportFrameMainContent_ReportViewer1").style.display = "block"; 
    });

    Just trying to give back to the comunity that as already gave me so much.

    Thank you all out there.

    Telmo

    Wednesday, October 10, 2012 12:20 PM