title: Ext.NET (Coolite) Dynamically created listener of Tabs in a Tabpanel doesn't find the ID of the HTMLEditor (object is undefined)
body: <p>I created a TabPanel on my aspx file. In my code behind, I dynamically create: the tabs inside it and also an HtmlEditor in each Tab. I also create a listener on each tab, so that when they get activated or show, the HtmlEditor in that tab get the focus.</p>
  
  <p>When i execute the program, I see that the tab have been created on my TabPanel. But before the web page is ready to use, an error occur saying that the objects Id in the listeners is undefined. So the listener doesn't work and the page does not load completely.</p>
  
  <p>The weird part, is that, if I add directly in my aspx file, a Tab in my Tab panel, and load the rest of my dynamic tab with listeners: All the Ids of the html editors are recognized, and all the listeners works perfectly. Except for the first tab, witch have no listener and was not created dynamically in this case.</p>
  
  <p>My theory on that, is that the tab at the index 0 of a TabPanel seems to lauch the listener of Activate() or Show() before the ID of the HtmlEditor control is save to the page.</p>
  
  <p>So I'm  wondering what I missed and how can I put listeners (activate or show) to each tab in a Tabpanel that will trigger the focus method of a control inside that Tab. And of course I want to generate all my tab dynamically.</p>
  
  <p>Can you help me ?</p>
  
  <p>I hope I was clear enough.</p>
  
  <p>Here's my <strong>Default.aspx</strong> page:</p>
  
  <pre><code>&lt;%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %&gt;
  &lt;%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %&gt;
  
  &lt;script runat="server"&gt; &lt;/script&gt;
  
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head runat="server"&gt;
      &lt;title&gt;Page sans titre&lt;/title&gt;
  &lt;/head&gt;
  &lt;body runat="server"&gt;
                &lt;ext:ScriptManager ID="CooliteScriptManager" runat="server" QuickTips="true" ScriptAdapter="Ext"&gt;
          &lt;/ext:ScriptManager&gt;
  
  &lt;form id="form" runat = "server"&gt;
         &lt;ext:Panel ID="PnFiche" runat="server" Border="false" Header="false" Frame="false"
                  AutoScroll="true" BodyStyle="padding: 10px; text-align: left;"&gt;
                  &lt;Body&gt;
                     &lt;ext:FormLayout ID="FormLayout1" runat="server" LabelWidth="150"&gt;
                      &lt;ext:Anchor runat="server"&gt;
                          &lt;ext:MultiField runat="server" FieldLabel="Indications / but de l'analyse" &gt;
                              &lt;Fields&gt;
                                  &lt;ext:FormPanel runat="server" Title="Indications / but de l'analyse" Width="1000" Collapsible="true"&gt;
                                      &lt;Body&gt;
                                          &lt;ext:TabPanel ID="TpIndications" runat="server" Width="1000" Height="250" EnableTabScroll="true"&gt;     
  
  
                                          &lt;/ext:TabPanel&gt;
                                      &lt;/Body&gt;
                                  &lt;/ext:FormPanel&gt;
                              &lt;/Fields&gt;
                          &lt;/ext:MultiField&gt;
                      &lt;/ext:Anchor&gt;
                      &lt;/ext:FormLayout&gt;
                  &lt;/Body&gt;
         &lt;/ext:Panel&gt;
         &lt;/form&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Here's my <strong>Default.aspx.cs</strong> page:</p>
  
  <pre><code>using System;
  using System.Configuration;
  using System.Data;
  using System.Linq;
  using System.Web;
  using System.Web.Security;
  using System.Web.UI;
  using System.Web.UI.HtmlControls;
  using System.Web.UI.WebControls;
  using System.Web.UI.WebControls.WebParts;
  using System.Xml.Linq;
  
  using Coolite.Ext.Web;
  
  public partial class _Default : System.Web.UI.Page 
  {
      protected void Page_Load(object sender, EventArgs e)
      {
          GenerateObjectTabPanel(TpIndications, "French", "Indication", null);
          GenerateObjectTabPanel(TpIndications, "English", "Indication", null);
      }
  
      private void GenerateObjectTabPanel(TabPanel theTabPanel, String theLanguage, String suffixeID, String TextToReplace)
      {
          HtmlEditor TheHtmlEditor = new HtmlEditor();
          TheHtmlEditor.ID = "Editeur_HTML_" + suffixeID + "_" + theLanguage;
          TheHtmlEditor.Height = 250;
          TheHtmlEditor.Width = 1000;
  
          if (!string.IsNullOrEmpty(TextToReplace))
          {
              TheHtmlEditor.Text = TextToReplace;
          }
  
          Tab TheTab = new Tab("Tab_" + suffixeID + "_" + theLanguage, theLanguage);
          TheTab.BodyControls.Add(TheHtmlEditor);
          TheTab.Listeners.Activate.Handler = "#{" + TheHtmlEditor.ID + "}.focus();";
  
          theTabPanel.Tabs.Add(TheTab);
  
      }
  }
  </code></pre>
  
  <p>Try modifying the <strong>default.aspx</strong> with one Tab already loaded and the listener works fine (But of course i don't want that since i want all my tab to be dynamically loaded):</p>
  
  <pre><code> &lt;%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %&gt;
      &lt;%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %&gt;
  
  &lt;script runat="server"&gt; &lt;/script&gt;
  
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head runat="server"&gt;
      &lt;title&gt;Page sans titre&lt;/title&gt;
  &lt;/head&gt;
  &lt;body runat="server"&gt;
                &lt;ext:ScriptManager ID="CooliteScriptManager" runat="server" QuickTips="true" ScriptAdapter="Ext"&gt;
          &lt;/ext:ScriptManager&gt;
  
  &lt;form id="form" runat = "server"&gt;
         &lt;ext:Panel ID="PnFiche" runat="server" Border="false" Header="false" Frame="false"
                  AutoScroll="true" BodyStyle="padding: 10px; text-align: left;"&gt;
                  &lt;Body&gt;
                     &lt;ext:FormLayout ID="FormLayout1" runat="server" LabelWidth="150"&gt;
                      &lt;ext:Anchor runat="server"&gt;
                          &lt;ext:MultiField runat="server" FieldLabel="Indications / but de l'analyse" &gt;
                              &lt;Fields&gt;
                                  &lt;ext:FormPanel runat="server" Title="Indications / but de l'analyse" Width="1000" Collapsible="true"&gt;
                                      &lt;Body&gt;
                                          &lt;ext:TabPanel ID="TpIndications" runat="server" Width="1000" Height="250" EnableTabScroll="true"&gt;     
  
                                                       &lt;Tabs&gt;
                                                          &lt;ext:Tab ID="TI_fr_CA" runat="server" Height="250" Width="1000" Title="test"&gt;
                                                              &lt;Body&gt;
                                                                  &lt;ext:HtmlEditor ID="EI_fr_CA" runat="server" Height="250" Width="1000" Visible="true"&gt;
                                                                  &lt;/ext:HtmlEditor&gt;
                                                              &lt;/Body&gt;
  
                                                          &lt;/ext:Tab&gt;
                                                       &lt;/Tabs&gt;
                                          &lt;/ext:TabPanel&gt;
                                      &lt;/Body&gt;
                                  &lt;/ext:FormPanel&gt;
                              &lt;/Fields&gt;
                          &lt;/ext:MultiField&gt;
                      &lt;/ext:Anchor&gt;
                      &lt;/ext:FormLayout&gt;
                  &lt;/Body&gt;
         &lt;/ext:Panel&gt;
         &lt;/form&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>