Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
1 year ago

Paginated report not embedding inside update panel ASP.net

Using Javascript SDK in asp.net framework application. The Power BI contianer DIV is not rendering the Paginated report under ASP.updatepanel. 

 

Outsite the updatepanel the report is rendering.

22 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi,

    I am using the ASP.NET WebForms framework and embedding the report using a JavaScript SDK approach.

    The `powerBIReportContainer` div does not display the report when it is placed inside an `<asp:UpdatePanel>`.

    Note: using Wizard forms as well. 

     

    When the `powerBIReportContainer` div is positioned outside the `</asp:UpdatePanel>`, the Power BI report renders correctly.

    Below is my code snippet. Could you please assist me with what changes I need to make in my JavaScript or any other solutions?

     

    </ContentTemplate>
    </asp:UpdatePanel>

    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/powerbi.js"></script>
    <asp:Button ID="btnGenerateReport" runat="server" Text="Generate Report" CssClass="genric_btn green" OnClick="btnGenerateReport_Click" />
    <div id="powerBIReportContainer" style="height:600px;width:100%;"></div>
    <script type="text/javascript">
    var embedUrl = '<%= EmbedUrl %>';
    var embedToken = '<%= EmbedToken %>';
    var reportId = '<%= ReportId %>';

    function embedPowerBIReport() {
    if (!embedUrl || !embedToken || !reportId) return;

    var models = window['powerbi-client'].models;
    var embedConfig = {
    type: 'report',
    isPaginatedReport: true,
    id: reportId,
    embedUrl: embedUrl,
    accessToken: embedToken,
    tokenType: models.TokenType.Embed,
    settings: {
    panes: {
    filters: { visible: false },
    pageNavigation: { visible: true }
    },
    navContentPaneEnabled: true
    }
    };
    var reportContainer = document.getElementById('powerBIReportContainer');
    powerbi.reset(reportContainer);
    var report = powerbi.embed(reportContainer, embedConfig);

    // Show page navigation after report is loaded
    report.on("loaded", function () {
    report.updateSettings({
    panes: {
    pageNavigation: { visible: true }
    }
    });
    });
    }

    window.onload = function () {
    embedPowerBIReport();
    };
    </script>
    </div>
    </div>

    </asp:Content>

    • Nasif_Azam's avatar
      Nasif_Azam
      Super User

      Hey Anonymous ,

      In your situation, the issue likely arises because the UpdatePanel is performing a partial postback, which can cause the embedded Power BI report to not render properly. The JavaScript code you're using to embed the Power BI report might be running before the UpdatePanel finishes updating its content, causing the report container (#powerBIReportContainer) to not be fully loaded or accessible.

       

      1. Trigger JavaScript After UpdatePanel Completes: The issue can be resolved by ensuring that the Power BI embedding code runs after the UpdatePanel has been updated. You can do this by hooking into the Sys.Application.add_load event, which ensures the Power BI report embedding happens only after the UpdatePanel is fully refreshed.

      Update your script to include Sys.Application.add_load like so:

      <script type="text/javascript">
      var embedUrl = '<%= EmbedUrl %>';
      var embedToken = '<%= EmbedToken %>';
      var reportId = '<%= ReportId %>';
      
      function embedPowerBIReport() {
          if (!embedUrl || !embedToken || !reportId) return;
      
          var models = window['powerbi-client'].models;
          var embedConfig = {
              type: 'report',
              isPaginatedReport: true,
              id: reportId,
              embedUrl: embedUrl,
              accessToken: embedToken,
              tokenType: models.TokenType.Embed,
              settings: {
                  panes: {
                      filters: { visible: false },
                      pageNavigation: { visible: true }
                  },
                  navContentPaneEnabled: true
              }
          };
          var reportContainer = document.getElementById('powerBIReportContainer');
          powerbi.reset(reportContainer);
          var report = powerbi.embed(reportContainer, embedConfig);
      
          // Show page navigation after report is loaded
          report.on("loaded", function () {
              report.updateSettings({
                  panes: {
                      pageNavigation: { visible: true }
                  }
              });
          });
      }
      
      // Trigger embedding after UpdatePanel updates
      Sys.Application.add_load(function () {
          embedPowerBIReport();
      });
      </script>

      2. Ensure Button Triggers UpdatePanel: Ensure that the btnGenerateReport button triggers the UpdatePanel refresh when clicked. Make sure the UpdatePanel wraps the content to be updated.

       

      3.Embedding After Postback: Use Sys.Application.add_load to execute the embedding script after the UpdatePanel completes its update during a postback.

       

      For Detailed Information:

      Embedding Power BI in Web Applications

      Power BI JavaScript API

      ASP.NET UpdatePanel Overview

       

       

      If you found this solution helpful, please consider accepting it and giving it a kudos (Like) it’s greatly appreciated and helps others find the solution more easily.


      Best Regards,
      Nasif Azam

      • Anonymous's avatar
        Anonymous
        Not applicable

        Thanks for your response. 

        As you suggested i added Sys.Application.add_load .  But still the PowerBI not rendering. FYI. the update panel is on ascx page. 

        // Trigger embedding after UpdatePanel updates
        Sys.Application.add_load(function () {
            embedPowerBIReport();
        });

         

    • Anonymous's avatar
      Anonymous
      Not applicable

      how to hide filter panel below code not working 

       

      panes: {
      filters: { expanded: false, visible: false },
      pageNavigation: { visible: true },
      parameters: { expanded: false, visible: false }// Hides the parameter pane }
      }

      • v-ssriganesh's avatar
        v-ssriganesh
        Community Support

        Hi Anonymous,
        Thanks for the update.

        Regarding your question about hiding the filter and parameter panes the configuration you're using (panes.filters and panes.parameters) is mainly applicable to Power BI interactive reports, not Paginated Reports.

        For Paginated Reports, the filter and parameter UI isn't controlled the same way. Instead, to hide the parameters panel, you can disable it when embedding using the supported option parameterPaneEnabled: false.

        If you're still seeing the panel, make sure you're using the latest version of the Power BI JavaScript SDK and that the report is truly a paginated report.

        If this helps, please mark it as “Accept as solution” and feel free to give a “Kudos” to help others in the community as well.
        Thank you.

    • v-ssriganesh's avatar
      v-ssriganesh
      Community Support

      Hello Anonymous,
      Just checking in have you been able to resolve this issue? If so, it would be greatly appreciated if you could mark the most helpful reply accordingly. This helps other community members quickly find relevant solutions.
      Please don’t forget to “Accept as Solution” and Give “Kudos” if the response was helpful.
      Thank you.

      • Anonymous's avatar
        Anonymous
        Not applicable

        not working Ssriganesh, can you guide me how to render power BI Paginated report inside <ASP.UpdatePanel>

  • v-ssriganesh's avatar
    v-ssriganesh
    Community Support

    Hello Anonymous,

    Could you please confirm if the solution provided has addressed your query?

    Thank you.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Ssriganesh, No soukution is working. Do you have any solution on how to render power BI Paginated report inside <ASP.UpdatePanel>.  I using below code but not working. 

     

    <asp:UpdatePanel ID="UpdatePanelReport" runat="server">
    <ContentTemplate>
    <div class="clear"></div>
    <div class="search-col3">
    <asp:Button ID="btnBack" runat="server" Text="<< Back" OnClick="btnBack_Click" CssClass="genric_btn " Visible="false" />
    <%--<asp:Button ID="btnGenerateReport" runat="server" Text="Generate Report" CssClass="genric_btn green" OnClick="btnGenerateReport_Click" />--%>
    </div>
    <%--<div id="powerBIReportContainer" style="height:600px;width:100%;"></div>--%>


    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/powerbi.js"></script>
    <asp:Button ID="btnGenerateReport" runat="server" Text="Generate Report" OnClick="btnGenerateReport_Click" />
    <div id="powerBIReportContainer" style="height:600px;width:100%;"></div>
    <script type="text/javascript">
    var embedUrl = '<%= EmbedUrl %>';
    var embedToken = '<%= EmbedToken %>';
    var reportId = '<%= ReportId %>';

    function embedPowerBIReport() {

    if (!embedUrl || !embedToken || !reportId) return;

    var models = window['powerbi-client'].models;
    var embedConfig = {
    type: 'report',
    isPaginatedReport: true,
    id: reportId,
    embedUrl: embedUrl,
    accessToken: embedToken,
    tokenType: models.TokenType.Embed,
    settings: {
    panes: {
    filters: { expanded: false, visible: false },
    pageNavigation: { visible: true },
    parameters: { expanded: false, visible: false }// Hides the parameter pane }
    },
    navContentPaneEnabled: true
    }
    };
    var reportContainer = document.getElementById('powerBIReportContainer');
    powerbi.reset(reportContainer);
    var report = powerbi.embed(reportContainer, embedConfig);

    report.on("loaded", function () {
    report.updateSettings({
    panes: {
    filters: { expanded: false, visible: false },
    pageNavigation: { visible: true },
    parameters: { expanded: false, visible: false }
    }
    });
    });
    }


    var prm = Sys.WebForms.PageRequestManager.getInstance();
    prm.add_pageLoaded(function () {
    powerbi.reset(document.getElementById('powerBIReportContainer'));
    embedPowerBIReport();
    });

    </script>
    </ContentTemplate>

    </asp:UpdatePanel>

  • Hi Anonymous 

    You're encountering a common issue when embedding Power BI reports—especially Paginated reports—within an ASP.NET Web Forms application that uses UpdatePanel for partial page updates. The problem arises because Power BI’s JavaScript SDK dynamically injects and controls the report rendering via the DOM, and UpdatePanel interferes with that process due to how it handles partial postbacks. Specifically, when a postback occurs inside an UpdatePanel, it replaces the inner HTML of the update panel, which can remove or disrupt the JavaScript-initialized Power BI container, preventing the Paginated report from rendering properly.

     

    When you place the Power BI embed code inside the UpdatePanel, the JavaScript execution might be interrupted or not re-triggered after the async postback, resulting in a blank or unresponsive Power BI container. However, placing the Power BI embedding logic outside the UpdatePanel avoids this problem because the full page lifecycle isn't interrupted, allowing the SDK to initialize and render the report correctly.

     

    To work around this, you have two options:

     

    Move the Power BI embedding logic outside the UpdatePanel and trigger updates via JavaScript or server-side logic that doesn’t require a partial postback.

     

    If you must use UpdatePanel, use the Sys.Application.add_load() method in ASP.NET AJAX to re-run your embedding JavaScript after every partial postback. For example:

    Sys.Application.add_load(function () {

    // your Power BI embed code here

    });

    This ensures the SDK re-initializes after the DOM is updated.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Poojara, i tried this, still not working.

      FYI.  the Power BI pagninated report should work inside update panel on a button Onclick  eg: OnClick="btnGenerateReport_Click"   this method fills  ReportId,
      EmbedUrl = embedInfo.embedUrl;
      EmbedToken = embedInfo.embedToken;

      Once the variable filled then should hit the Javascript SDK . Below are the code snippet i am trying inside update panel but not working. 

       

      <asp:Button ID="btnGenerateReport" runat="server" Text="Generate Report" CssClass="genric_btn green" OnClick="btnGenerateReport_Click" />
      <div id="powerBIReportContainer" style="height:600px;width:100%;"></div>
      <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/powerbi.js"></script>
      <script type="text/javascript">

       

      Sys.Application.add_load(function () {

      embedPowerBIReport();

      });

       


      var embedUrl = '<%= EmbedUrl %>';
      var embedToken = '<%= EmbedToken %>';
      var reportId = '<%= ReportId %>';

      function embedPowerBIReport() {
      if (!embedUrl || !embedToken || !reportId) return;

      var models = window['powerbi-client'].models;
      var embedConfig = {
      type: 'report',
      isPaginatedReport: true,
      id: reportId,
      embedUrl: embedUrl,
      accessToken: embedToken,
      tokenType: models.TokenType.Embed,
      settings: {
      panes: {
      filters: { expanded: false, visible: false },
      pageNavigation: { visible: true },
      parameters: { expanded: false, visible: false }
      },
      navContentPaneEnabled: false,
      parameterPaneEnabled: false
      }
      };
      var reportContainer = document.getElementById('powerBIReportContainer');
      powerbi.reset(reportContainer);
      var report = powerbi.embed(reportContainer, embedConfig);

      // Show page navigation after report is loaded
      report.on("loaded", function () {
      report.updateSettings({
      panes: {
      pageNavigation: { expanded: false, visible: true },
      filters: { visible: false },
      parameters: { expanded: false, visible: false }
      },
      parameterPaneEnabled: false
      });
      });
      }

       

       

       


      </script>

       

      • v-ssriganesh's avatar
        v-ssriganesh
        Community Support

        Hello Anonymous,
        We regret the inconvenience caused. Please consider raising a Microsoft support ticket for further investigation. You can explain all the troubleshooting steps you have taken to help them better understand the issue.

        You can create a Microsoft support ticket with the help of the link below:
        https://learn.microsoft.com/en-us/power-bi/support/create-support-ticket

        If this helps, please accept it as a solution and drop a "Kudos" so other members can find it more easily.

        Thank you.