[CLOSED] TabPanel DirectEvent TabChange and Page_Load

  1. #1

    [CLOSED] TabPanel DirectEvent TabChange and Page_Load

    When I add the TabChange DirectEvent to a TabPanel, it causes the Page_Load to fire on each TabChange (I would assume it would).
    I am trying to use the Page_Load to dynamically add controls to the clicked tab. 2 Questions:

    1) How do I know which tab was clicked (seems like ActiveTabIndex should have this value) ?

    2) Only the dynamic controls on the first tab are actually rendered, I can never get controls on the other tabs to render?

    Here is a simple example:

    <%@ Page Language="C#" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            switch (tpMain.ActiveTabIndex)
            {
                case 0:
                    tb1.Controls.Add(new Ext.Net.Label("Hello Tab 1"));
                    break;
                case 1:
                    tb2.Controls.Add(new Ext.Net.Label("Hello Tab 2"));
                    break;
            }
        }
        protected void tpMain_Change(object sender, Ext.Net.DirectEventArgs e)
        {
        }
    </script>
    
    <!DOCTYPE html>
    
    <html>
        <head runat="server">
            <title>TabPanel Example</title>
        </head>
        <body>
            <ext:ResourceManager runat="server" />
            <ext:TabPanel ID="tpMain" runat="server">
                <Items>
                    <ext:Panel 
                        ID="tb1" 
                        runat="server" 
                        Title="Tab1">
                    </ext:Panel>
                    <ext:Panel 
                        ID="tb2" 
                        runat="server" 
                        Title="Tab2">
                    </ext:Panel>
                </Items>
                <DirectEvents>
                    <TabChange OnEvent="tpMain_Change"></TabChange>
                </DirectEvents>
            </ext:TabPanel>
        </body>
    </html>
    Thank you for your help, Craig
    Last edited by Daniil; Jul 11, 2014 at 5:07 PM. Reason: [CLOSED]
  2. #2
    Hi @chulcy,

    1) How do I know which tab was clicked (seems like ActiveTabIndex should have this value) ?
    The TabPanel's ActiveTabIndex server property is not maintained across requests. You should send this info from a client manually. You could do that via a DirectEvent's ExtraParams.

    2) Only the dynamic controls on the first tab are actually rendered, I can never get controls on the other tabs to render?
    During a DirectEvent it is not enough just to put a control to the Controls collection. You should use the methods like Render and AddTo. This example demonstrates the approach.
    https://examples2.ext.net/#/XRender/Basic/Add_Items/

    By the way, please use the Items collection for Ext.NET controls instead of the Controls collection.
  3. #3
    The TabPanel's ActiveTabIndex server property is not maintained across requests. You should send this info from a client manually. You could do that via a DirectEvent's ExtraParams.
    It will be maintained if you add a form on the page.
    <form runat="server">

Similar Threads

  1. Replies: 2
    Last Post: May 16, 2013, 3:02 PM
  2. Replies: 7
    Last Post: Oct 05, 2012, 1:49 PM
  3. TabPanel load panel in TabChange
    By naina in forum 1.x Help
    Replies: 1
    Last Post: Aug 02, 2011, 3:43 PM
  4. Replies: 3
    Last Post: Oct 17, 2010, 1:22 PM
  5. [CLOSED] [1.0] TabPanel - Solution for no TabChange on Page_Load
    By bsnezw in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jul 06, 2010, 4:27 PM

Tags for this Thread

Posting Permissions