Skip to content Skip to sidebar Skip to footer

How Can I Get A Tabcontainer Id Using Jquery Or Javascript?

I have a tabcontainer in an updatepanel and I would like to display gridview below the tabcontainer. inside of tab container, it is ok to change when I press each tabs but I cannot

Solution 1:

First you can get the id of any element from a jquery object or native javascript object like so

// jquery get id of html element
   $(myJquerySelector)[0].id
   $(myJquerySelector).attr('id');

   // native js get id of html element
   document.querySelector(myNativeSelector).id;
   document.getElementById(theID).id;

But your problem is beyond that. To get the id of the active tab, you need to just get that tab

   $('.ui-tabs-active')[0].id// will give you the id of the active tab

Then to pass that to your server you will need AJAX. So something like:

   $.post('/my/server/path', { id : $('.ui-tabs-active')[0].id });

That will post the id of the active tab to your server and c#.

Solution 2:

For a straight javascript function I use this below to get the active tab:

var tab = document.getElementById('tabContainer');
 var currentTabIndex = tab.control.get_activeTabIndex();
 var currentTabId = tab.control._tabs[currentTabIndex]._tab.id;

Then, use some AJAX to get the id back to the server.

Post a Comment for "How Can I Get A Tabcontainer Id Using Jquery Or Javascript?"