Answered by:
Unwanted RenderContents Event When Updating an UpdatePanel

Question
-
User1557998713 posted
These are two buttons that each activate a Pdf that are displayed in an iframe, one on top of the other. I am seeing that putting the second iframe with the Pdf in the same space of the first one, a RenderContents event of the first one occurs and it is eliminated. Can 2 iframes be in the same place?
I need to prevent the second RenderContents from running automatically. I have prevented it by code but it does not work because when you do not enter anything in the WebControl, it disappears.
I have 2 updatepanel and inside each one there is an ImageButton and a webcontrol with a "FilePath" Property. When clicking on the ImageButton, in codebehind in the RenderContents event, an iframe is entered in the corresponding webcontrol. In the two iframe two different pdfs are shown and according to the "FilePath" property, an html iframe is generated to show the pdf or an empty iframe is generated if "FilePath" is = null.
The problem happens when I have already clicked on the first ImageButton and the iframe with the first Pdf is displayed. So if I click on the second ImageButto, the RenderContents event is generated and the second iframe is shown with the second Pdf on screen, but then a RenderContents event is automatically generated for the first iframe that empties it of content.
iframes are displayed in the same space, one on top of the other. Is that why you force to repaint the first iframe when loading the second one?
By having each webcontrol in a different updatepanel, I don't understand why the webcontrol from a different updatepanel is refreshed.
Also, I cannot use ViewState because the iframes are from a pdf where the user can go to the next page and the pdf would not be replaced as it was previously in the iframe, besides it works much slower.<%@ Register Assembly="Cls_iFrameViewer" Namespace="Name_iFrameViewer" TagPrefix="cc1"%>
<div id="Form_Buscar_LayoutPanel" class="smart-pl1 Form_Buscar_LayoutPanel">
<!-- FIRST UPDATEPANEL -->
<asp:updatepanel ID="Form_UpdatePanel_Botones1" runat="server">
<ContentTemplate><div id="Form_Botones_Superior1" class="smart-pl1 Botones_Superior">
<span id="Form_PdfViewer_Button" runat="server" class="smart-pl1 Button_Visor">
<asp:ImageButton ID="Form_PdfViewer_Button_Image" runat="server" class="smart-pl1 Button_Visor_Image" ImageUrl="../images/cry/buscar/formatos/pdf.png" Visible="true"
OnClientClick="return Fcn_Visores_OnClient_Click(Name_Controles_Visores.Pdf, null, null);" OnClick="Fcn_AppVisores_Button_Click"/>
</span></div>
<cc1:iFrameViewer_Show ID="Form_PdfViewer" class="smart-pl1 pdfopen" runat="server" Cnt_Visor="Pdf"/>
</ContentTemplate>
</asp:updatepanel><!-- SECOND UPDATEPANEL -->
<asp:updatepanel ID="Form_UpdatePanel_Botones2" runat="server">
<ContentTemplate><div id="Form_Botones_Superior2" class="smart-pl1 Botones_Superior">
<span id="Form_BrowserViewer_Button" runat="server" class="smart-pl1 Button_Visor">
<asp:ImageButton ID="Form_BrowserViewer_Button_Image" runat="server" class="smart-pl1 Button_Visor_Image" ImageUrl="../images/cry/buscar/formatos/web.png" Visible="true"
OnClientClick="return Fcn_Visores_OnClient_Click(Name_Controles_Visores.Browser, null, null);" OnClick="Fcn_AppVisores_Button_Click"/>
</span>
</div><cc2:iFrameViewer_Show ID="Form_BrowserViewer" class="smart-pl1 browseropen" runat="server" Cnt_Visor="Browser"/>
</ContentTemplate>
</asp:updatepanel></div>
Saturday, July 11, 2020 5:42 AM
Answers
-
User1557998713 posted
I was able to fix this by using UpdateMode = "Conditional" in updatepanel. This way the unwanted RenderContents event does not occur in the second updatepanel.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Sunday, July 12, 2020 3:47 AM
All replies
-
User409696431 posted
What does Fcn_AppVisores_Button_Click do? You are calling that same function in both buttons.
Saturday, July 11, 2020 6:49 AM -
User1557998713 posted
Retrieves the name of the button pressed to execute the corresponding function.
Saturday, July 11, 2020 9:56 AM -
User409696431 posted
I assume that is not all it does. What is the code for that function?Saturday, July 11, 2020 10:58 AM -
User1557998713 posted
There are many unimportant lines of code. What matters is that I am seeing that putting the second iframe with the Pdf in the same space of the first one, a RenderContents event of the first one occurs and it is eliminated. Can 2 iframes be in the same place?
Saturday, July 11, 2020 11:09 AM -
User409696431 posted
A description leaves only guessing, which is not helpful. There can be two iframes in the same page, but of course they can't be in the same place. What do you really mean by that? That's why I asked to see the code, to see what you are really doing. Feel free
to post a stripped down version, the minimum required to illustrate the problem you are having.
If you want to show only one iframe or the other, using buttons to flip back and forth, remove the one you are no longer showing before replacing it with the other. (Again, I'm having to guess what you are really trying to do.)
Saturday, July 11, 2020 1:31 PM -
User1557998713 posted
I was able to fix this by using UpdateMode = "Conditional" in updatepanel. This way the unwanted RenderContents event does not occur in the second updatepanel.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Sunday, July 12, 2020 3:47 AM