Adding Tab using codebehind

  1. #1

    Adding Tab using codebehind



    Consider the following: I want to add a Tab to a TabPanel from codebehind. What do I do wrong in this example?

        <ext:Button ID="btnBind" runat="server" >
            <AjaxEvents>
                <Click OnEvent="btnBind_Clicked">
                </Click>
            </AjaxEvents>
        </ext:Button>
        <br />
        <ext:TabPanel ID="tabsCenterPanel" runat="server" Border="true" Height="600">
        </ext:TabPanel>
        protected void btnBind_Clicked(object sender, AjaxEventArgs e)
        {
            testTab = new Tab("t1", "Hello Tab");
            tabsCenterPanel.Tabs.Add(testTab);
        }
  2. #2

    RE: Adding Tab using codebehind

    Hi gevik,

    Adding Tabs during an AjaxEvent/AjaxMethod is not currently supported.


    Can you add the Tab during the Page_Load and set Hidden="true", then use .Show() during the AjaxEvent?


    Geoffrey McGill
    Founder & CEO
  3. #3

    RE: Adding Tab using codebehind

    Thank you. I will try.
  4. #4

    RE: Adding Tab using codebehind

    <P class=MsoNormal style="MARGIN: 0in 0in 10pt">Are there any best practices for Coolite. For example what should one do and what shouldn't coming from classic asp.net development model.



  5. #5

    RE: Adding Tab using codebehind

    Sorry to hijack this thread but I have the same issue and the Hide(), Show() has no affect.

    I do this at page load and all tab panels show regardless of call to Hide().
  6. #6

    RE: Adding Tab using codebehind

    Hi,

    Please see the following example (Tab6)
    http://examples1.ext.net/#/TabPanel/Basic/Show_Hide/
    Vladimir Shcheglov
    Sr. Developer
  7. #7

    RE: Adding Tab using codebehind



    hi, gevik. I think these code will help you.

    if (mo.RefEntityPath.Trim().Length>0)
                    {
                        strTab = BuildNewTabString("centerMain", mo.ObjectText, tabID, true, "Loding.....", mo.RefEntityPath);
                        mi.Listeners.Click.Handler = strTab;
                    }
    The BuildNewTabString as following:
    private string BuildNewTabString(string tabPanelID, string title, string tabID, bool closable, string maskMsg, string pageURL)
            {
                string strNewTab = @"
                        var tab = #{#TABPANEL#}.getComponent('#TABPANELID#');
                        if (!tab) {
                        tab=#{#TABPANEL#}.add({ 
                        id: '#TABPANELID#', 
                        title: '#TITLE#', 
                        closable:#CLOSABLE#,                    
                        autoLoad: {
                            showMask: true,
                            url: '#URL#',
                            mode:'iframe',
                            maskMsg: '#MASKMSG#'
                        }                    
                    });#{#TABPANEL#}.setActiveTab(#TABPANELID#);}";
    
    
                strNewTab = strNewTab.Replace("#TABPANEL#", tabPanelID).Replace("#TABPANELID#", tabID).Replace("#CLOSABLE#", closable.ToString().ToLower()).Replace("#MASKMSG#", maskMsg).Replace("#URL#", pageURL).Replace("#TITLE#", title);
    
    
                return strNewTab;
            }
    , and you can get the tab id in the server, so you can manage those tabs in your will.<NOSCRIPT></NOSCRIPT>
  8. #8
    Hi animalisme,
    I has tried your snipnet and it works! But the TabPanel doesn't set Active tab when i click the menu item again. what's wrong here?
    thank you so much for resolving my problem!
    Regards,
    Anh Nguyen Tuan
    Last edited by tuananhdnx; Sep 30, 2011 at 10:25 AM.
  9. #9
    Function build new tab should be below (bug when active tab again)
    private string BuildNewTabString(string tabPanelID, string title, string tabID, bool closable, string maskMsg, string pageURL)
            {
                string strNewTab = @"
                        var tab = #{#TABPANEL#}.getComponent('#TABPANELID#');
                        if (!tab) {
                        tab=#{#TABPANEL#}.add({ 
                        id: '#TABPANELID#', 
                        title: '#TITLE#', 
                        closable:#CLOSABLE#,                    
                        autoLoad: {
                            showMask: true,
                            url: '#URL#',
                            mode:'iframe',
                            maskMsg: '#MASKMSG#'
                        }                    
                    });}
    #{#TABPANEL#}.setActiveTab(#TABPANELID#);";
     
     
                strNewTab = strNewTab.Replace("#TABPANEL#", tabPanelID).Replace("#TABPANELID#", tabID).Replace("#CLOSABLE#", closable.ToString().ToLower()).Replace("#MASKMSG#", maskMsg).Replace("#URL#", pageURL).Replace("#TITLE#", title);
     
     
                return strNewTab;
            }
    Thanks to animalisme again :)
    Last edited by tuananhdnx; Oct 03, 2011 at 9:52 AM.
  10. #10
    Hi,

    The following sample demonstrates adding a new Tab to a TabPanel from code-behind and setting the ActiveTab, see

    http://examples1.ext.net/#/XRender/Basic/Add_Items/

    Hope this helps.
    Geoffrey McGill
    Founder & CEO

Similar Threads

  1. [CLOSED] adding handler listener in codebehind
    By ashton.lamont in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: May 05, 2010, 4:50 PM
  2. FormPanel CodeBehind item adding BUG
    By davutengin in forum 1.x Help
    Replies: 3
    Last Post: Jun 18, 2009, 1:26 PM
  3. FormPanel CodeBehind item adding
    By davutengin in forum 1.x Help
    Replies: 0
    Last Post: Jun 15, 2009, 5:53 AM
  4. [CLOSED] Grid adding removing columns in codebehind
    By methode in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: Feb 24, 2009, 2:51 AM
  5. Replies: 3
    Last Post: Mar 28, 2008, 3:57 PM

Posting Permissions