Sunday, March 11, 2012

Trying to understand conditional nested UpdatePanel

Hi

Update Panel has two modes - Always and Conditional.

If you mark as always, then whether or not, the controls inside that Update Panel renders back to the server, that panel is always post back to the server and do the normal processing as in normal Postback.

But when you mark the Update Panel as Conditional, then only that Panel gets updated from where the Controls renders them. But there are some situations like If you have make the update Panel as Nested,the its Parent Panel also gets Updated. I think there is no way to stop the Parent Panel to be updated.

Hope this will help you out.

Thanx

Bye


deepakleo2003:

But there are some situations like If you have make the update Panel as Nested,the its Parent Panel also gets Updated. I think there is no way to stop the Parent Panel to be updated.

Hello,

I think that is not correct. I'm using nested updatepanels from the early ctps and betas, and it works the following way:

When a child updatepanel is forced to update itself some way (using the triggers section in the aspx/clicking a button inside it/calling the update method in the code behind), only that up will be update, the parent up won't!

Here is an example:

<%@. Page Language="C#" AutoEventWireup="true" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="frmMain" runat="server">
<asp:ScriptManager runat="server" EnablePartialRendering="true" ID="TheScriptManager" />
<asp:UpdatePanel ID="aupParent" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Button ID="btnParent" runat="server" Text="Update the parent (and all childs of course)" />
<%= "Parent panel last updated at:" + DateTime.Now.ToString( )%><asp:UpdatePanel ID="aupChild" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Button ID="btnChild" runat="server" Text="Update only the child" />
<%= "Child panel last updated at:" + DateTime.Now.ToString( )%></ContentTemplate>
</asp:UpdatePanel>
</ContentTemplate>
</asp:UpdatePanel>
</form>
</body>
</html>

Hi

Yes i am somewhat wrong. You can force the Parent Panel to be updated by setting ChildrenAsTriggers Property of the Update Panel as False. But my other Concepts are right.

Bye

Perhaps I didn't state my question clearly. I understand that it won't render back to the page in a nested update panel. But is there anyway to make it such that sibling UpdatePanels won't execute their page_load etc methods when they aren't being the ones updated?

example:

<asp:ScriptManagerID="ScriptManager1"runat="server"EnablePartialRendering="true"/>

<div>

<asp:UpdatePanelID="OuterPanel"runat="Server"UpdateMode="conditional">

<ContentTemplate>

<asp:LabelID="outerLabel"runat="server"Text="OuterLabel"></asp:Label>

<asp:UpdatePanelID="test1"runat="Server"UpdateMode="conditional">

<ContentTemplate>

<uc1:WebUserControlID="WebUserControl1"runat="server"/>

</ContentTemplate>

</asp:UpdatePanel>

<asp:UpdatePanelID="test2"runat="server"UpdateMode="conditional">

<ContentTemplate>

<uc1:WebUserControlID="WebUserControl2"runat="server"/>

</ContentTemplate>

</asp:UpdatePanel>

</ContentTemplate>

</asp:UpdatePanel>

</div>

Is there any way to prevent test2 from executing it's page_load for the user control if someone is clicking on test1?


Hi

I think that you can do that by making OuterPanel ChildrensAsTrigger = false.

hope this helps out

bye


Hi

Thanx for the response and link

Any other link is greatly appreciated

Bye


MattBell:

Is there any way to prevent test2 from executing it's page_load for the user control if someone is clicking on test1?

Hello,

I think there is no way to prevent that event, because:

"An asynchronous postback behaves much like a synchronous postback. Allthe server page life-cycle events occur, and view state and form dataare preserved. However, in the rendering phase, only the contents oftheUpdatePanel control are sent to the browser. The rest of the page remains unchanged."

I get this fromPartial-Page Rendering Overview

No comments:

Post a Comment