[CLOSED] Creating tabs on the fly in an AjaxEvent

  1. #1

    [CLOSED] Creating tabs on the fly in an AjaxEvent

    Is this the correct way to create some tabs on the fly after pushing a button?


    *** * * *foreach (DataRow locale in templateLocales.Tables[0].Rows)** * * *{
    ** * * * * *string loc = locale["Locale"].ToString().Replace("-", "");
    ** * * * * *Coolite.Ext.Web.Tab newTab = new Coolite.Ext.Web.Tab("tab" + loc, locale["Locale"].ToString());
    ** * * * * *Coolite.Ext.Web.FitLayout newFit = new Coolite.Ext.Web.FitLayout();
    ** * * * * *Coolite.Ext.Web.HtmlEditor newEdit = new Coolite.Ext.Web.HtmlEditor();
    ** * * * * *newEdit.ID = "html" + loc;
    ** * * * * *newFit.Controls.Add(newEdit);
    ** * * * * *newTab.BodyControls.Add(newFit);
    ** * * * * *this.tabPanelTemplates.Tabs.Add(newTab);
    ** * * *}

    If I debug it, the code runs as expected but still the Ajax call response is empty: {}
  2. #2

    RE: [CLOSED] Creating tabs on the fly in an AjaxEvent

    Hi,

    Creating Coolite controls during AjaxEvent is not supported yet. At the moment, you can create controls on client side only or during first page load or postback*


  3. #3

    RE: [CLOSED] Creating tabs on the fly in an AjaxEvent

    Ok,
    I moved the code to the PageLoad function but it still does not work properly.
    Now the tabs are there but there is nothing inside.

            if (!IsPostBack)
            {
                DataSet locales = DB.BaseDB.GetLocaleList();
                foreach (DataRow locale in locales.Tables[0].Rows)
                {
                    string loc = locale["LocaleCode"].ToString().Replace("-", "");
                    Coolite.Ext.Web.Tab newTab = new Coolite.Ext.Web.Tab("tab" + loc, locale["LocaleCode"].ToString());
                    this.tabPanelTemplates.Tabs.Add(newTab);
                    Coolite.Ext.Web.FitLayout newFit = new Coolite.Ext.Web.FitLayout();
                    Coolite.Ext.Web.HtmlEditor newEdit = new Coolite.Ext.Web.HtmlEditor();
                    newEdit.ID = "html" + loc;
                    newFit.Controls.Add(newEdit);
                    newTab.BodyControls.Add(newFit);
                }
            }
  4. #4

    RE: [CLOSED] Creating tabs on the fly in an AjaxEvent

    Hi,

    I used this way:

    newTab.BodyContainer.Controls.Add(newFit);


    Matteo

  5. #5

    RE: [CLOSED] Creating tabs on the fly in an AjaxEvent

    Hi,

    try to add editor to Items collection of FitLayout
    newFit.Items.Add(newEdit);
    *
  6. #6

    RE: [CLOSED] Creating tabs on the fly in an AjaxEvent

    Hi Vlad and thanks for the reply (I'm answering so late because I was sick for a while)
    Unfortunately it still doesn't work. No editor is shown in the tabs at all.

    I think the fit layout is not added to the tab contents at all because the html source shows this:

    <div id="tabCreateMassMailContent_htmlenGB_Container" style="display:inline;">
  7. #7

    RE: [CLOSED] Creating tabs on the fly in an AjaxEvent

    Hi,

    Here is my test case which works fine. Can you update and retest again?
    <%@ Page Language="C#" ValidateRequest="false" %>
    
    <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title></title>
        <script runat="server">
            protected void Page_Load(object sender, EventArgs e)
            {
                if (!IsPostBack)
                {
                    for (int i = 0; i < 5; i++)
                    {
                        Coolite.Ext.Web.Tab newTab = new Coolite.Ext.Web.Tab("tab" + i, i.ToString());
                        this.TabPanel1.Tabs.Add(newTab);
                        Coolite.Ext.Web.FitLayout newFit = new Coolite.Ext.Web.FitLayout();
                        Coolite.Ext.Web.HtmlEditor newEdit = new Coolite.Ext.Web.HtmlEditor();
                        newEdit.ID = "html" + i;
                        newFit.Items.Add(newEdit);
                        newTab.BodyControls.Add(newFit);
                    }
                }
            }
        </script>
    </head>
    <body>
        <form id="formMain" runat="server">
            <ext:ScriptManager ID="ScriptManager1" runat="server" />
            
            <ext:TabPanel ID="TabPanel1" runat="server" Height="300">
            
            </ext:TabPanel>
        </form>
    </body>
    </html>
  8. #8

    RE: [CLOSED] Creating tabs on the fly in an AjaxEvent

    *It works now thanks.

    I think the secret was adding the newly created tab to the tab collection before adding the content to the tab.


Similar Threads

  1. [CLOSED] Move tabs Tabs Style Google Chrome
    By majunior in forum 1.x Legacy Premium Help
    Replies: 7
    Last Post: Apr 30, 2013, 12:58 PM
  2. Replies: 0
    Last Post: Mar 27, 2012, 10:01 AM
  3. Replies: 2
    Last Post: Jul 21, 2010, 12:28 PM
  4. [CLOSED] Creating a SVN setup
    By r_honey in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jul 10, 2010, 7:39 AM
  5. [CLOSED] Add Tab to tabs collection through AjaxEvent button
    By methode in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Oct 06, 2008, 8:28 AM

Posting Permissions