Problem in getting the ID of the current active tab in TabPanel

  1. #1

    Problem in getting the ID of the current active tab in TabPanel

    Hi,

    I'm trying to get the ID of the active tab, but every time it seems the active tab returns 0.

    Code:
    idNome = TabPanel1.FindControl(TabPanel1.ActiveItem).ID;

    What do I have to do?
  2. #2
    I think it's too difficult to do what you want, because user is changing Active Tab on client side, and you have to add hidden field which will track what tab is active. Do you use this in DirectEvent's Handler? If you do, it's much easier to use ExtraParams. Try following code:

    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            Window win = new Window
            {
                Height = 250,
                Width = 600,
                Closable = false,
                Title = "Scrollable Tabs",
                Layout = "Fit"
            };
    
            TabPanel tabs = new TabPanel
            {
                ID = "TabPanel1",
                Border = false,
                MinTabWidth = 100,                      
                ActiveTabIndex = 6,
                Plugins =
                {
                    new TabScrollerMenu { PageSize = 5 }
                }
            };
            
            tabs.Add(new Ext.Net.Panel { Title = "Our First Tab" });
            
            int index = 1;
            
            while (index <= 11)
            {
                Ext.Net.Panel tab = new Ext.Net.Panel
                {
                    ID = "Tab_" + index,
                    Title = "Tab # " + index.ToString(),
                    Html = "Tab " + index.ToString(),
                    Closable = true,
                    Border=false,
                    Padding = 6
                };
                
                tabs.Items.Add(tab);
                index++;
            }
    
            win.Items.Add(tabs);
            
            this.Form.Controls.Add(win);
        }
        
        /// <summary>
        /// Handler for Button DirectEvent Click 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void ButtonClickHandler(object sender, DirectEventArgs e) {
            string activeTabId = e.ExtraParams["activeTabId"];
            if (activeTabId == string.Empty)
            {
                X.Msg.Notify("Active Tab Id", "No active tab").Show();
            } else
            {
                Ext.Net.Panel activeTab = (Ext.Net.Panel)Form.FindControl("TabPanel1").FindControl(activeTabId);
                X.Msg.Notify("Active Tab Id", activeTabId).Show();
            	
            }
        }
    
    </script>
    
    <!DOCTYPE html>
    
    <html>
    <head id="Head1" runat="server">
        <title>Scrollable Tabs with TabScrollerMenu Plugin - Ext.NET Examples</title>
    </head>
    <body>
        <form id="Form1" runat="server">
            <ext:ResourceManager ID="ResourceManager1" runat="server" />
            
            <h1>Scrollable Tabs with TabScrollerMenu Plugin</h1>
            
            <ext:Button ID="Button1" runat="server" Text="Click me">
                <DirectEvents>
                    <Click OnEvent="ButtonClickHandler">
                        <ExtraParams>
                            <ext:Parameter runat="server" Name="activeTabID" Value="#{TabPanel1}.getActiveTab() != null ? #{TabPanel1}.getActiveTab().getId() : ''" Mode="Raw"></ext:Parameter>
                        </ExtraParams>
                    </Click>
                </DirectEvents>
            </ext:Button>
        </form>
    </body>
    </html>
  3. #3

    RESOLVE: Problem in getting the ID of the current active tab in TabPanel

    Hello, I managed to solve the problem using the following code:

     Dim tabactivo = tabpanel1.ActiveTab.ID

Similar Threads

  1. [CLOSED] TabPanel - perform page load only when active
    By cwolcott in forum 2.x Legacy Premium Help
    Replies: 4
    Last Post: May 09, 2012, 4:48 PM
  2. [CLOSED] Error when binding KeyMap to not active Panel in TabPanel
    By Fredrik in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Apr 02, 2012, 1:52 PM
  3. [CLOSED] Set active tab tabpanel
    By Pablo_Azevedo in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Jun 22, 2011, 8:03 AM
  4. Replies: 3
    Last Post: Oct 17, 2010, 1:22 PM
  5. TabPanel set active tab on server
    By logicspeak in forum 1.x Help
    Replies: 1
    Last Post: Aug 25, 2010, 4:40 PM

Tags for this Thread

Posting Permissions