Wednesday, March 28, 2012

Programatically hiding Tabs in TabContainer is not hiding the HeaderText

I wanted to hide/Show one of the TabPanel programatically.

so basically I am doing this.TabContainer.Tabs[1].Visible = false;

Even thought the body of that TabPanel is hiding , the Header Text is still visible without a Tab background.

Please let me know if anyone has found a solution if faced the same problem.

Thanks

Maybe have a look at how the sample does it with script in its ToggleHidden method? Or try the .Enabled property?

it's better to use multiview and view as tab, it's works without problem

this is the code:

MultiView1.ActiveViewIndex = 2

you don't have to hide or show, just send to multiview control the index of the view you want to acitvate.


Actually there is one very simple solution:

tab.visible = false;

tab.headertext=""

And this works perfectly for me.


I use tabPanel._hide() and tabPanel._show(); on the client side. Where tabPanel = $find('tabPanelClientID');

Can anyone tell me how to do the same AND compatible with server refresh of the page... ie. If my client javascript code alters which tabs are visible using _show() and _hide(), then a button to submit the form is pressed can the tab display propertied be maintained across refreshes? hope that makes sense... :)

Currently if I do that above then returned page is reset to the original tab settings.

My scenario is...

I have 4 tabs. as the user selects from various drops downs, tabpanel2 is either hidden or kept shown. the form is eventually submitted to the server and is refreshed, but the tabs are not as they had previosuly been set!!!

I was looking for some kind of proprty like ClientState...?

help


you can also use:

TabContainer1.Tabs(3).Enabled =

False

...then you don't have to hit both the visible and headertext. You also won't have to put the text back that way either.

Dan Ribar


I have a question related to the way you are using the client-side script to show/hide the tabs. I have a tab container (clientID = tcMain) and 4 tab panels (tp1, tp2, tp3, tp4). When I tried to use the following to hide a panel I'm getting a javascript error stating "null is null or not an object". How are you able to resolve the show/hide functions?

My code:

$find('tp2')._hide(); --> failed with the above error

$find('tcMain').get_tabs()[1]._hide(); --> failed with the same error as above

$find('tcMain_tp2')._hide(); --> failed

document.getElementById('tcMain_tp2').style.visibility = 'hidden'; --> failed, could not get visibility property

Can you send me your code?


From the online sample at http://ajax.asp.net/ajaxtoolkit/Tabs/Tabs.aspx:

function ToggleTab(enable, tabNumber) {
$find('<%=TabContainer1.ClientID%>').get_tabs()[tabNumber].set_enabled(enable);
}

hides or shows the tab

function EnableTab(tabNumber)
{
$find('<%=TabContainer1.ClientID%>').set_activeTabIndex(tabNumber);
}

enables the tab which unhides it

would do the trick.

No comments:

Post a Comment