ASP.NET update panel nested refreshing

453 views Asked by At

This code is in a user control . and i am providing a sample code structure to get an overview .

<Update Panel UpdateMode= "Conditional">
<panel></panel>
<panel>
<button></button>
</panel>
<updatepanel UpdateMode="Conditional"></updatepanel>
</Updatepanel>

so when i click a button in the second panel , i am supposed to hide that panel and it is happening but simultaneously the other panels are getting refreshed . what could be the possible reason for that ?

1

There are 1 answers

0
Jesse Johnson On

Based on the code snippet you may have a couple issues to fix:

  1. Make sure you have a ScriptManager on the page with EnablePartialRendering="true"
  2. Correct your markup by making the <UpdatePanel> elements ASP.NET UpdatePanel controls by prefixing them with "asp:".
  3. Add UpdateMode="Conditional" to both of your UpdatePanel controls
  4. Move the sections you want to update asynchronously into the UpdatePanel controls.

Example

<asp:ScriptManager ID="MyScriptManager" EnablePartialRendering="true" runat="server"></asp:ScriptManager>
    <asp:UpdatePanel ID="MyUpdatePanel" runat="server">
        <ContentTemplate>
            <asp:Label ID="Label1" runat="server" Text="This is a label!"></asp:Label>
            <asp:Button ID="Button1" runat="server" Text="Click Me" />
        </ContentTemplate>
    </asp:UpdatePanel>

The following article is a great resource to learn more about the UpdatePanel with details on it's capabilities.

Understanding Partial Page Updates with ASP.NET AJAX