This is a migrated thread and some comments may be shown as answers.

Create dynamic closable RadTab and RadMultiPage server - side

4 Answers 178 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
fabio selingrim
Top achievements
Rank 1
fabio selingrim asked on 03 Oct 2008, 01:42 PM
Hi,

I'd like to know how to dynamically add a RadTab control with 'Close' feature SERVER-SIDE.

I've alread created the tabs, but i cannot add a 'Close' gif on them.

thanks in advance

4 Answers, 1 is accepted

Sort by
0
Paul
Telerik team
answered on 06 Oct 2008, 02:08 PM
Hello fabio,

Please find below a sample code snippet that shows the needed approach.

protected void Page_Load(object sender, EventArgs e)  
{  
    if (!Page.IsPostBack)  
    {  
        RadTab tab1 = new RadTab();  
        tab1.Text = "tab1";  
        RadTabStrip1.Tabs.Add(tab1);  
 
        RadTab tab2 = new RadTab();  
        tab2.Text = "tab2";  
        RadTabStrip1.Tabs.Add(tab2);  
 
        RadTab tab3 = new RadTab();  
        tab3.Text = "tab3";  
        RadTabStrip1.Tabs.Add(tab3);  
 
        RadTabStrip1.DataBind();  
    }  
 
    foreach (RadTab myTab in RadTabStrip1.GetAllTabs())  
    {  
        Literal myText = new Literal();  
        myText.Text = myTab.Text;  
        myTab.Controls.Add(myText);  
 
        HtmlImage myImage = new HtmlImage();  
        myImage.Src = "delete.gif";  
        myImage.Alt = "delete";  
        myImage.Style.Add("margin-left""10px");  
        myImage.Attributes.Add("onclick"string.Format("deleteTab('{0}')", myText.Text));  
        myTab.Controls.Add(myImage);  
    }  
}   


Greetings,
Paul
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Carlos
Top achievements
Rank 1
answered on 09 Oct 2008, 02:20 PM
thanks ..

what would be the method code of deleteTab() ??
0
Carlos
Top achievements
Rank 1
answered on 09 Oct 2008, 02:26 PM
I using this method

function deleteTab(tab)
       {
           var
tabStrip = $find("<%= RadTabStrip1.ClientID %>");
           
           var
tabToSelect = tab.get_nextTab();
           if (!tabToSelect)
               
tabToSelect = tab.get_previousTab();
               
           tabStrip.get_tabs().remove(tab);
           
           if (tabToSelect)
               tabToSelect.set_selected(true);
       }


but i get this error tab.get_nextTab is not a function

why ?
0
Scott R
Top achievements
Rank 1
answered on 10 Oct 2008, 03:11 AM
It's "tab.get_nextSibling()" and "tab.get_previousSibling()".
Tags
TabStrip
Asked by
fabio selingrim
Top achievements
Rank 1
Answers by
Paul
Telerik team
Carlos
Top achievements
Rank 1
Scott R
Top achievements
Rank 1
Share this question
or