locked
How to know what is the current active tab in tabcontainer? RRS feed

  • Question

  • User-10248131 posted

    Hello,

    I have a TabContainer with 4 TabPanels in it.

    I have couple buttons outside the TabContainer.

    When I click on any button, I need to know which tabpanel is active.

    I use TabContainer1.ActiveTabIndex, it always return 0 which is the firstone.

    Why?

    Thanks.

    Thursday, October 10, 2013 10:50 AM

Answers

All replies

  • User-10248131 posted

    I tried to use     Protected Sub TabContainer1_ActiveTabChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TabContainer1.ActiveTabChanged

    to find out TabContainer1.ActiveTabIndex, however, it won't be hit.

    I also tried frontend:

        <cc1:TabContainer runat="server" OnActiveTabChanged="TabContainer1_ActiveTabChanged"
    it won't be hit neither.

    Isn't it supposed to be hit? why the event won't get fired?

    Thanks.

    Thursday, October 10, 2013 11:03 AM
  • User-10248131 posted

    I found the reason why the event is not fired, by default the  AutoPostBack="false", so once I changed it to true, it will be fired.

    However, issue is still there, in the TabContainer1_ActiveTabChanged event, the TabContainer1.ActiveTabIndex is always 0, no matter how I switched the tab back and forth

    Thursday, October 10, 2013 11:10 AM
  • User-933407369 posted

    hi mdivk,

    you can try to add codes below in page-load.

    Code behind:

    If Session("ActiveTab") IsNot Nothing Then
                    TabContainer1.ActiveTabIndex = Convert.ToInt32(Session("Activetab"))
    End If

    Please read the reference below for more information:

    http://www.vbforums.com/showthread.php?614260-RESOLVED-Ajax-ActiveTabChanged

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, October 11, 2013 2:12 AM
  • Sunday, October 13, 2013 11:41 PM