ajax active tab id
-
13-07-2021 - |
Question
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>
Solution
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.
OTHER TIPS
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.