TabContainer with Dynamic TabPanel Bug?

Last post 10-31-2007 5:25 PM by GSpies. 1 replies.

Sort Posts:

  • TabContainer with Dynamic TabPanel Bug?

    10-31-2007, 4:41 PM
    • Member
      175 point Member
    • GSpies
    • Member since 07-25-2006, 8:42 AM
    • Posts 38

    I am adding tabs to the container in OnInit by itterating through session data

     The control being added are .asc controls with an event that fire when a delete button is clicked.

     
    Everything works great except when the last tab in the container is deleted - not the last one leaving 0, but the last one in the list. Then none of them get rendered.

    I have even tried using FindControl on the TabPanel.Tabs.Remove(control) and that gives the same problem with the last tab.

    All other deletes/rebuilds work fine.
     

    Anyone else had this bug and have some sort of fix as this is pretty much a showstopper? 

  • Re: TabContainer with Dynamic TabPanel Bug?

    10-31-2007, 5:25 PM
    Answer
    • Member
      175 point Member
    • GSpies
    • Member since 07-25-2006, 8:42 AM
    • Posts 38

    On further investigation, it seems that the problem lies with .ActiveTab .

    When the last tab is deleted ActiveTab seems to contain nothing useful and thus all tabs get rendered with display:none  . The logical error, if it is even on, is in:

            protected override void RemovedControl(Control control)
            {
                TabPanel controlTabPanel = control as TabPanel;
                if (control != null && controlTabPanel.Active && ActiveTabIndex < Tabs.Count)
                {
                    EnsureActiveTab();
                }
                controlTabPanel.SetOwner(null);
                base.RemovedControl(control);
            }

     The reason being that if you remove the last tabpanel (and it is active) the tab's count has already been redudeced by one.

    Since all other tabs are inactive, they are hidden. This one is removed and voila - "empty" tab panel.

    I solved it by setting ActiveTab to the last one I added, though I would think that seeing as a tab is active when added (without my code) one should be active when being removed too.

    Also, I am not really following the use of _cachedActiveTabIndex in ActiveTabIndex as _activeTabIndex is set onEnsureActiveTab and then ActiveTabIndex is read - which could lead to _cachedActiveTabIndex being returned.

    Much of a muchness I supose but it took me long enough to find this "feature".

    My suggestion : RemovedControl should be a bit smarter by setting ActiveTabIndex to the last tab, if there are none active (ie, ActiveTabIndex > Tabs.Count and Tabs.Count > 0 ). Or something.

Page 1 of 1 (2 items)