Nesting UpdatePanels

Another question today - can you nest UpdatePanel controls? Well I hadn't tried so off I jolly well went and did so...

 <%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC 
  "-//W3C//DTD XHTML 1.0 Transitional//EN" 
  "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="https://www.w3.org/1999/xhtml">
<head runat="server"></head>
<body>
  <form runat="server">
    <div>
      <asp:ScriptManager runat="server" />
      <asp:UpdatePanel UpdateMode="Conditional"  runat="server">
        <ContentTemplate>
          <%= "Outer: " + new Random().Next(1,100).ToString() %>
          <asp:Button runat="server" Text="Button" />
          <asp:UpdatePanel UpdateMode="Conditional" runat="server">
            <ContentTemplate>
              <%= "Inner: " + new Random().Next(1,100).ToString() %>
              <asp:Button runat="server" Text="Button" />
            </ContentTemplate>
          </asp:UpdatePanel>
        </ContentTemplate>
      </asp:UpdatePanel>
    </div>
  </form>
</body>
</html>

And of course it works quite happily. A good reference (which I didn't find 'til later) is the latter part of this page in the ASP.NET AJAX tutorials.

Technorati tags: asp.net, ajax, updatepanel