Forum Discussion
Paginated report not embedding inside update panel ASP.net
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();
});
Hey Anonymous ,
Since Sys.Application.add_load didn't resolve the issue, here are some other things to try:
Ensure UpdatePanel wraps both the button and the report container to ensure they are updated together.
<asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:Button ID="btnGenerateReport" runat="server" Text="Generate Report" /> <div id="powerBIReportContainer" style="height:600px;"></div> </ContentTemplate> </asp:UpdatePanel>Use PageRequestManager for postback completion:
var prm = Sys.WebForms.PageRequestManager.getInstance(); prm.add_pageLoaded(function () { embedPowerBIReport(); });Reset the report if already embedded:
var prm = Sys.WebForms.PageRequestManager.getInstance(); prm.add_pageLoaded(function () { powerbi.reset(document.getElementById('powerBIReportContainer')); embedPowerBIReport(); });Check for any JavaScript errors in the browser's developer tools console.
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
- Anonymous1 year agoNot applicable
Hi Nasif,
I used the code you suggested . But still not working and erros in browser's developer tools console.
Is that anything i am missing.
<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>
- v-ssriganesh1 year ago
Community Support
Hello Anonymous,
Thank you for reaching out to the Microsoft Fabric Forum Community and thanks to Nasif_Azam for the solid guidance provided so far.Since you're still seeing issues and there are errors in the browser's developer console, the next best step would be to review those specific error messages. They’ll help us identify whether the problem is related to variable values, the timing of script execution or something else in the page lifecycle.
Could you please share the exact error messages you're seeing?
This will help us pinpoint what might be going wrong and guide you with a precise fix.
- Anonymous1 year agoNot applicable
I used this code, still not working. I cannot see any error message in console as well.
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_pageLoaded(function () {
powerbi.reset(document.getElementById('powerBIReportContainer'));
embedPowerBIReport();
});