title: can not access control inside asp.net updatepanel
body: <p>I use this official sample from Microsoft:</p>
  
  <p>When I try to access the MyLabel from codebehind in the click event the MyLabel is NULL.</p>
  
  <p>Why this?</p>
  
  <pre><code>&lt;asp:ScriptManager ID="PageScriptManager" runat="server" /&gt;
  &lt;asp:Button ID="MyButton" Text="Click Me" runat="server" onClick="MyButton_Clicked" /&gt;
  &lt;asp:UpdatePanel ID="MyUpdatePanel" runat="server"&gt;
  &lt;Triggers&gt; 
      &lt;asp:AsyncPostBackTrigger ControlID="MyButton" EventName="Click" /&gt;
  &lt;/Triggers&gt;
      &lt;ContentTemplate&gt;
      &lt;asp:Label ID="MyLabel" Text="OldText" runat="server" /&gt;
      &lt;/ContentTemplate&gt;
  &lt;/asp:UpdatePanel&gt;
  
  
  
  
  private void MyButton_Clicked(object sender, EventArgs e) 
   {   
    MyLabel.Text = "NewText!";
   } 
  </code></pre>
  
  <p><strong>UPDATE</strong> This code does not work Why? The MyLabel is always NULL on server side ??</p>
  
  <pre><code>&lt;%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
      CodeFile="Default.aspx.cs" Inherits="_Default" %&gt;
  
  &lt;asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent"&gt;
  &lt;/asp:Content&gt;
  &lt;asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"&gt;
  
    &lt;asp:ScriptManager runat="server" ID="xx"&gt;  
    &lt;/asp:ScriptManager&gt;
  
   &lt;asp:ImageButton OnClick="OnClickRefreshButton" ID="RefreshImageButton" runat="server" Width="100px" /&gt;
  &lt;asp:UpdatePanel ID="MyUpdatePanel" runat="server"&gt; 
      &lt;Triggers&gt;
           &lt;asp:AsyncPostBackTrigger ControlID="RefreshImageButton" EventName="Click" /&gt; 
      &lt;/Triggers&gt; 
      &lt;asp:ContentTemplate&gt; 
        &lt;asp:Label ID="MyLabel" Text="OldText" runat="server" /&gt;
      &lt;/asp:ContentTemplate&gt;
  &lt;/asp:UpdatePanel&gt;  
  &lt;/asp:Content&gt;
  
  protected void OnClickRefreshButton(Object sender, ImageClickEventArgs e) 
          {       
  
              MyLabel.Text = "NewText!";
          }
  </code></pre>