Programmatic rendering of the tab control does not show the tab styling

Posted on 2007-08-02
Last Modified: 2008-01-09
Hi Guys,

The following code does not render the styles of the tab.
They look like hyper link but works a tabs.

public AjaxControlToolkit.TabContainer CreateWorktabs()
AjaxControlToolkit.TabContainer TabContainer = new AjaxControlToolkit.TabContainer();
AjaxControlToolkit.TabPanel TabPanelWorks = new AjaxControlToolkit.TabPanel();
AjaxControlToolkit.TabPanel TabPanelRequest = new AjaxControlToolkit.TabPanel();
AjaxControlToolkit.TabPanel TabPanelTasks = new AjaxControlToolkit.TabPanel();
 TabContainer.Width = Unit.Pixel(700);
TabContainer.Height = Unit.Pixel(540);

TabContainer.CssClass = "ajax__tab_xp";
//TabContainer.Attributes.Add("Style", "strstyle");
// TabContainer.Attributes.Add("CssClass","ajax__tab_xp");
TabContainer.BorderStyle = BorderStyle.NotSet;
TabContainer.ActiveTabIndex = 2;

TabPanelWorks.HeaderText = "Works";
TabPanelWorks.ID = "tabPanelWorks";
TabPanelRequest.HeaderText = "Request";
TabPanelRequest.ID = "TabPanelRequest";
TabPanelTasks.HeaderText = "Task";
TabPanelTasks.ID = "TabPanelTasks";
return TabContainer;
Question by:FunCoder
    LVL 2

    Accepted Solution

    Is the style sheet in which the css class you are attempting to use linked to the page where the tabs live?  Also, not sure if you meant to do this, but aren't the lines where you are adding the style attribute commented out?  Finally, I believe tabs are all rendered as links, so you may have another style for 'a' in your style sheet that is overriding the specific class you mention in the code.  I think 'a' modifiers are last in the hierarchy so they will override any specific classes assigned.

    For example:

    a { color:red }
    .mystyle { color:blue }

    will render a red link if 'mystyle' is applied to a hyperlink, where:

    a { color:red }
    .mystyle a { color: blue }

    would render a blue link.

    Author Comment

    //TabContainer.CssClass = "ajax__tab_xp";
                //TabContainer.Attributes.Add("Style", "strstyle");
    was commented out cos I tried it
    I added  .a tag stuff as well

    LVL 2

    Expert Comment

    Okay, if you have the toolkit installed where you are deploying or testing, it should have a default stye sheet which is probably not getting picked up by your page. lists the default styles in here: AjaxControlToolkit\Tabs\Tabs.css.  You'll want to ensure that the default styles for the tab controls are incorporated into your own style sheet if the toolkit css is not included in your deployment.

    Author Comment

    It is almost working now except that, it only works when you refresh the page using F5.


    Author Comment

    It is almost working now except that, it only works when you refresh the page

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Join & Write a Comment

    This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
    Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
    Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
    Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now