AjaxControlToolkit TabContainer: TabPanel.Visible="False" should not display header text

2. May 2007

If you set the visible property of TabPanels within your TabContainer to false, it still shows the Header Text in the page when rendered. What should happen is any TabPanels with Visible set to False should be hidden. A fix for this has been posted to the AJAX Control Toolkits Issue Tracker, but we have to wait for the next release to get the fix in place.

Is there a work around?

Below is an Inherited class I created using the fix described to allow me to fix this issue myself until the next release.

public class FixedTabContainer : AjaxControlToolkit.TabContainer
{
   protected override void RenderHeader(HtmlTextWriter writer)
   {
      
foreach (TabPanel panel in Tabs)
      
{
         
if (panel.Visible) //added this line
            
panel.RenderHeader(writer);
      }
   }
}

Well, actually, the above code doesn't work!

Compiler Error Message: CS0122: 'AjaxControlToolkit.TabPanel.RenderHeader(System.Web.UI.HtmlTextWriter)' is inaccessible due to its protection level

I then tried to Inherit from the AjaxControlToolkit.TabPanel class within my namespace, but that doesn't get around the protection level of the RenderHeader method.

Conclusion

Basically, the only way to fix this before the next release comes (that is assuming they put the fix in the next release) is to implement this fix in the toolkit's source code yourself and then compiling it in. This is actually something I don't like to do just in case I make some change to the toolkit manually and then forget to carry that over when upgrading to the latest version when it comes out, but it is nice you have the ability to do is since the AJAX Control Toolkit is Open Source.

UPDATE:
Here's a rather easy workaround that I found to this issue...
 You just set Visible to False and set the HeaderText to a blank string if you don't want the TabPanel to be shown. This worked perfectly in the instance I needed it to work. Below is a simplified version of what I did.

<ajaxToolkit:TabPanel runat="server" ID="tabPeople" Visible='<%# ShouldBeShow() %>' HeaderText='<%# ShouldBeShow() ? "People" : "" %>'>

 

asp.net

Comments

vainternet.com
vainternet.com
6/12/2007 11:51:00 PM #
Alternativly you can define it in the code behind like so.

Tab3.Visible = false;
Tab3.HeaderText = "";

Just access the tab, not the container
Orlando
Orlando
10/1/2007 5:42:00 PM #
Hello there,

I have a problem using the TabPanel, when i set the property enabled=false in design time and then i try to enable it in execution time, all the controls inside of the TabPanel are set to ReadOnly, I can't change to not ReadOnly ¿someone can help me please?

Is very urgent to me, i apreciate if some one can tellme how can i fix this problem.

Thanks.
Dave
Dave
10/31/2007 6:01:00 PM #
Try this:

tabPanel1.HeaderText = string.Empty;
Oswaldo Rodriguez
Oswaldo Rodriguez
12/5/2007 9:25:00 PM #
Thanks, you just saved me a lot of time!!!
7/8/2010 8:07:45 AM #
Pingback from shoel.blogtown.co.nz

» Bug in Ajax Tab Panel Control Shoel's i-log book