title: Set Visibility of Panel Inside Update Panel From Code behind From An Update Panel
body: <p>I have simplified and probably made a typo or two below, but I am trying to show and hide the visibility of pnl2, this code however doesn't work.  I thought as long as the panel was in another update panel I can control visibility.</p>
  
  <p>Oddly enough if I debug this in Visual studio, and F10 all the way through it, it shows the visibility correctly, but when I hit my Last F10 and the page loads, it's always incorrect.</p>
  
  <pre><code>&lt;asp:UpdatePanel runat="server" UpdateMode="Always" ID="updPanel1"&gt;
  &lt;ContentTemplate&gt;
  &lt;asp:Panel runat="Server" ID="pnl1"/&gt;
  &lt;asp:Button runat="Server" ID="hidePanel2" OnClick="HidePanel2"/&gt;
  &lt;/ContentTemplate&gt;
  &lt;/UpdatePanel&gt;
  
  
  &lt;asp:UpdatePanel runat="server" UpdateMode="Always" ID="updPanel2"&gt;
  &lt;ContentTemplate&gt;
  &lt;asp:Panel runat="Server" ID="pnl2"/&gt;
  &lt;/ContentTemplate&gt;
  &lt;/UpdatePanel&gt;
  
  protected void hidePanel2(object sender, EventArgs e)
  {
  if (pnl2.Visible == true)
  {
      pnl2.Visible = false;
  }else
  {
      pnl2.Visible = true;)
  }
  </code></pre>