Microsoft Most Valuable Professional

Chris Pietschmann

An MVP From Wisconsin



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

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" : "" %>'>

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:
Categories: General
Posted by crpietschmann on Wednesday, May 02, 2007 1:52 PM
Permalink | Comments (4) | Post RSSRSS comment feed

Related posts

Comments

vainternet.com

Tuesday, June 12, 2007 7:51 PM

vainternet.com

Alternativly you can define it in the code behind like so.

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

Just access the tab, not the container

Orlando

Monday, October 01, 2007 1:42 PM

Orlando

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

Wednesday, October 31, 2007 2:01 PM

Dave

Try this:

tabPanel1.HeaderText = string.Empty;

Oswaldo Rodriguez

Wednesday, December 05, 2007 5:25 PM

Oswaldo Rodriguez

Thanks, you just saved me a lot of time!!!

Add comment


(Will show your Gravatar icon)  

  Country flag

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]



Live preview

Tuesday, January 06, 2009 9:09 PM

About the author

I'm Chris Pietschmann, go to the About Me page to learn more about me.

Search

Sponsors

Web.Maps.VE - ASP.NET AJAX Virtual Earth Mapping Server Control

Recent comments

Disclaimer


This work is licensed under a Creative Commons Attribution 3.0 United States License, unless explicitly stated otherwise within the posted content.
© Copyright 2004 - 2009 Chris Pietschmann