0

i have an ajax control toolkit tabcontainer. How can i determine the ID of the active tab using javascript or jquery? i.e below it would be Tab_Monitor if that tab was active.

I have tried all the samples but cannot find the solution.

thanks damo

<asp:TabContainer ID="TabContainerMain" runat="server" ActiveTabIndex="4" Width="100%"
Height="100%" CssClass="" ViewStateMode="Enabled">
   <asp:TabPanel runat="server" HeaderText="test" ID="Tab_Monitor">
      <ContentTemplate>
         <div class="TabControls">
             <p>Howdy, I'm in Section Tab_Monitor.</p>
         <div>
insomiac
  • 5,648
  • 8
  • 45
  • 73
user1438082
  • 2,740
  • 10
  • 48
  • 82

2 Answers2

2

Code not tested. As I can remeber, when any tab is selected, .ajax__tab_active class is applied to that div. So the following can be used to grab the ID of the selected tab

alert($(".ajax__tab_active").first().attr('id'));

You can customize the selector based on your need.

Tariqulazam
  • 4,535
  • 1
  • 34
  • 42
  • Thanks very much. doesn't give me the exactly the Tab ID but it will work . the value it returns is TabContainerMain_Tab_Monitor_Tab , where i had expected just the ID of the tab which is Tab_Monitor – user1438082 Oct 23 '12 at 19:28
  • I am glad that it worked. As it has a runat="server" tag, the generated id will be different than the declared id of that control. – Tariqulazam Oct 23 '12 at 20:00
2

Ajax Control Toolkit TabContainer client side component supports get_activeTab and get_activeTabIndex methods.

You can access this methods using the following JS code:

$find('<%=TabContainerMain.ClientID %>').get_activeTab();

Edit:

You can also review How to select a tab from TabCointainer (AjaxToolKit) where guys suggest the same.

Community
  • 1
  • 1
Maxim Kornilov
  • 5,675
  • 1
  • 24
  • 35