title: Set Focus on Dynamically added control in AJAX Update Panel
body: <p>I need to set the focus on a Label i have dynamically added. Here is my AJAX Panel</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional"&gt;
      &lt;ContentTemplate&gt;
          &lt;asp:Panel ID="pnlProgress" runat="server" class="summaryBox" 
                     Style="width: 650px; height: 225px" ScrollBars="Auto"&gt;
              &lt;asp:PlaceHolder ID="plcHolder" runat="server"&gt;&lt;/asp:PlaceHolder&gt;
              &lt;asp:Button ID="btnTrigger" runat="server" OnClick="Button1_Click"
                          Style="visibility: hidden" /&gt;&lt;/asp:Panel&gt;
      &lt;/ContentTemplate&gt;
  &lt;/asp:UpdatePanel&gt;
  </code></pre>
  
  <p>Here is my c# code</p>
  
  <pre class="lang-cs prettyprint-override"><code>label.Text = "SomeText";
  label.ID = "lblMessage" + messageNumber;
  if (heading)
  {
      label.Attributes.Add("style", "font-weight: bold;")                
  }
  UpdatePanel1.ContentTemplateContainer.Controls.Add(label);
  plcHolder.Controls.Add(label);
  </code></pre>
  
  <p>I tried to <code>SetFocus(label)</code> after the <code>label.Attributes</code>, but it didn't work. I can't do it in JScript as I can't <code>GetElement</code> on any of the Labels I've created dynamically. Any clues? I need to focus as the Panel has scrollbars and I want it to scroll to  the last dynamically added Label</p>