This is a migrated thread and some comments may be shown as answers.
The TabTemplate property of the RadTab doesn't work
2 Answers 36 Views
This is a migrated thread and some comments may be shown as answers.
Foenix
Top achievements
Rank 1
Foenix asked on 14 Mar 2011, 02:52 PM
Hello!
I'm trying to customize RadTabStrip tab's appearance using the TabTemplate property. But it looks like this property doesn't work at all. I implemented a class to be used as a template:
public class TestTabTpl : ITemplate
{
    public void InstantiateIn(Control container)
    {
        // TODO: Implement this method
        Label lblCtrl = new Label();
  
        lblCtrl.Text = "Text message";
  
        container.Controls.Add(lblCtrl);
    }
}

Then when I'm trying to use it as a TabTemplate
protected void Page_Load(object sender, EventArgs e)
{
    foreach (RadTab tab in RadTabStrip1.Tabs)
    {
        tab.TabTemplate = new TestTabTpl();
    }
}
it doesn't work.

I've tried to test if the TestTabTpl class works using RadGrid:
protected void Page_Load(object sender, EventArgs e)
{
    foreach (GridBoundColumn col in RadGrid1.Columns)
    {
        col.FilterTemplate = new TestTabTpl();
    }
}

And it works like a charm!

Could you please verify if I'm using this property correctly or confirm that it can not be used from code?
Thank you!

2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 1
answered on 15 Mar 2011, 02:30 PM
Hello Foenix,

Take a look at the following help article.
Adding and Editing Templates at Runtime

Thanks,
Shinu.
0
Foenix
Top achievements
Rank 1
answered on 16 Mar 2011, 03:53 PM
Thank you very much, Shinu!

This article was very helpful.

To all:
If you want to customize your tabs appearance without creating all tabs on the fly you can use following approach:
protected void Page_Load(object sender, EventArgs e)
{
    foreach (RadTab tab in RadTabStrip1.Tabs)
    {
        switch (tab.Value)
        {
            case "Value1":
                CustomTab1 tabTpl1 = new CustomTab1();
                tabTpl1.InstantiateIn(tab);
                break;
            case "Value2":
                CustomTab2 tabTpl2 = new CustomTab2();
                tabTpl2.InstantiateIn(tab);
                break;
            default:
                CustomTabDef tabTplDef = new CustomTabDef();
                tabTplDef.InstantiateIn(tab);
                break;
        }
    }
}
Asked by
Foenix
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Foenix
Top achievements
Rank 1
Share this question
or