I'm trying to hide a tab when the user clicks a menu item from a webexplorerbar. I have this code below , but can't get the selected tab to be set as hidden/visable
function HideTab()
{
var webTab = $find("<%=WebTab1.ClientID%>");
var tab = webTab.getTabAt(0);
tab.set_visible(false);
}
Hi Naish,
The names of get/set properties on client mostly match with corresponding properties on server. Since Visible is property of base WebControl, that is not supported by tab item and the visibility is defined by Hidden.If you are not sure exact names of methods or do not want to consult docs, then you may put the "debugger;" line and look at available methods for object which you are interested in. Below I wrote an example for you to hide tabs on client.
<script type="text/javascript">function hideTab(index){ var webTab = $find('<%=WebTab1.ClientID%>'); if(!webTab) return; //debugger; if(index == null) { index = webTab.get_selectedIndex(); if(index < 0) { alert('There is no selected tab'); return; } } var tab = webTab.getTabAt(index); if(!tab) alert('There is no tab at index:' + index); else tab.set_hidden(true);}</script> <ig:WebTab ID="WebTab1" runat="server" Height="240px" Width="470px"> <Tabs> <ig:ContentTabItem runat="server" Text="Tab 1"> </ig:ContentTabItem> <ig:ContentTabItem runat="server" Text="Tab 2"> </ig:ContentTabItem> <ig:ContentTabItem runat="server" Text="Tab 3"> </ig:ContentTabItem> <ig:ContentTabItem runat="server" Text="Tab 4"> </ig:ContentTabItem> </Tabs> </ig:WebTab> <input type="button" value="hide 0" onclick="hideTab(0)" /> <input type="button" value="hide selected" onclick="hideTab()" />
Thanks. Worked.