Dynamically created listener of Tabs in a Tabpanel doesn't find the ID of the HTMLEditor (object is undefined)

  1. #1

    Dynamically created listener of Tabs in a Tabpanel doesn't find the ID of the HTMLEditor (object is undefined)

    Hi Ext.NET,

    Here's my problem:

    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.

    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.

    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.

    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.

    So i 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.

    Can you help me ?

    I hope i was clear enough.

    Regards,

    Romston

    Here's my code for my Default.aspx page:

    <%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>
    <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
    
    <script runat="server"> </script>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Page sans titre</title>
    </head>
    <body runat="server">
                  <ext:ScriptManager ID="CooliteScriptManager" runat="server" QuickTips="true" ScriptAdapter="Ext">
            </ext:ScriptManager>
    
    <form id="form" runat = "server">
           <ext:Panel ID="PnFiche" runat="server" Border="false" Header="false" Frame="false"
                    AutoScroll="true" BodyStyle="padding: 10px; text-align: left;">
                    <Body>
                       <ext:FormLayout ID="FormLayout1" runat="server" LabelWidth="150">
                        <ext:Anchor runat="server">
                            <ext:MultiField runat="server" FieldLabel="Indications / but de l'analyse" >
                                <Fields>
                                    <ext:FormPanel runat="server" Title="Indications / but de l'analyse" Width="1000" Collapsible="true">
                                        <Body>
                                            <ext:TabPanel ID="TpIndications" runat="server" Width="1000" Height="250" EnableTabScroll="true">     
        
                                            </ext:TabPanel>
                                        </Body>
                                    </ext:FormPanel>
                                </Fields>
                            </ext:MultiField>
                        </ext:Anchor>
                        </ext:FormLayout>
                    </Body>
           </ext:Panel>
           </form>
    
    </body>
    </html>


    Here his the code for my Default.aspx.cs page:

    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);
    
        }
    }


    Try modifying the default.aspx 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):

    <%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>
    <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
    
    <script runat="server"> </script>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Page sans titre</title>
    </head>
    <body runat="server">
                  <ext:ScriptManager ID="CooliteScriptManager" runat="server" QuickTips="true" ScriptAdapter="Ext">
            </ext:ScriptManager>
    
    <form id="form" runat = "server">
           <ext:Panel ID="PnFiche" runat="server" Border="false" Header="false" Frame="false"
                    AutoScroll="true" BodyStyle="padding: 10px; text-align: left;">
                    <Body>
                       <ext:FormLayout ID="FormLayout1" runat="server" LabelWidth="150">
                        <ext:Anchor runat="server">
                            <ext:MultiField runat="server" FieldLabel="Indications / but de l'analyse" >
                                <Fields>
                                    <ext:FormPanel runat="server" Title="Indications / but de l'analyse" Width="1000" Collapsible="true">
                                        <Body>
                                            <ext:TabPanel ID="TpIndications" runat="server" Width="1000" Height="250" EnableTabScroll="true">     
    
                                                         <Tabs>
                                                            <ext:Tab ID="TI_fr_CA" runat="server" Height="250" Width="1000" Title="test">
                                                                <Body>
                                                                    <ext:HtmlEditor ID="EI_fr_CA" runat="server" Height="250" Width="1000" Visible="true">
                                                                    </ext:HtmlEditor>
                                                                </Body>
                                                              
                                                            </ext:Tab>
                                                         </Tabs>
                                            </ext:TabPanel>
                                        </Body>
                                    </ext:FormPanel>
                                </Fields>
                            </ext:MultiField>
                        </ext:Anchor>
                        </ext:FormLayout>
                    </Body>
           </ext:Panel>
           </form>
    
    </body>
    </html>
  2. #2
    Please do not multi-post the same topic.

    http://forums.ext.net/showthread.php?10857

    If you original thread goes unsolved, please feel free to *bump* that thread. Generally threads go unanswered because of lack of information.
    Geoffrey McGill
    Founder

Similar Threads

  1. Replies: 4
    Last Post: Oct 01, 2012, 9:58 AM
  2. [CLOSED] Add Activate Event to dynamically created tabs
    By rnachman in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Jun 02, 2011, 5:37 PM
  3. Replies: 10
    Last Post: Nov 12, 2010, 1:13 PM
  4. [CLOSED] Unable to render controls within dynamically created TabPanel
    By Hari_CSC in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Mar 29, 2010, 10:04 AM
  5. Replies: 4
    Last Post: Dec 22, 2009, 12:09 PM

Tags for this Thread

Posting Permissions