We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Tab script add tab and remove tab

Is there any way to add tab or remove tab when click button?

4 Replies

MS Muralishankar Sundaram Syncfusion Team September 11, 2014 12:50 PM UTC

Hi Siang, 

Thank you for using Syncfusion products. 

Yes, By handling the Tabstrip object you can easily add and remove the tab manually. Please refer the following code snippet:

<code>

[CS]

protected void button2_Click(object Sender, Syncfusion.Web.UI.WebControls.Shared.ButtonAdvControl.ButtonAdvClickEventArgs e)

        {

            tab.Items.RemoveAt(tab.Items.Count-1);

        }

 

        protected void ButtonAdv1_Click(object Sender, Syncfusion.Web.UI.WebControls.Shared.ButtonAdvControl.ButtonAdvClickEventArgs e)

        {

            tab.Items.Add(new TabStripItem() { Text = "Sample" });

        }

</code>

we have attached the sample solution for add and remove tab action. 

Regards,

Muralishankar


Attachment: Tab_add_4918ce7b.zip


SI Siang September 12, 2014 07:20 AM UTC

How about if using tab strip with multi page?

Is there any sample?


SI Siang September 15, 2014 08:39 AM UTC

Hi, Muralishankar Sundaram

Actually I facing the problem when create new TabStripItem with a PageView.

When I click the button to create the TabStripItem with PageView at the first time, it worked ok.
However when I click the button second time or more, the TabStripItem is create but the PageView is replaced the previous PageView.

No matter how many times I click the button, only the Items in the TapStrip are increasing but the total PageView in the MultiPage keep remain at 1.

Here is my code.
-------------------------------------------------------------------------------------------------------------------------------------
[asp .net]
 <syncfusion:TabStrip ID="TabStripControl1" runat="server" Width="1024px" AutoFormat="Multiple Pages" MultiPageID="MultiPageControl1">
</syncfusion:TabStrip>                         
                                   
<syncfusion:MultiPage ID="MultiPageControl1" runat="server">
</syncfusion:MultiPage>

-------------------------------------------------------------------------------------------------------------------------------------
[CS]

int id = TabStripControl1.Items.Count + 1;

Label newLabel = new Label() { ID = "LabelControl"+id, Text = "Label"+id };

PageView newPageView = new PageView() { ID = "PageViewControl" + id };
newPageView.Controls.Add(newLabel);

MultiPageControl1.Controls.Add(newPageView);

TabStripItem newTabStripItem = new TabStripItem() { ID = "TabStripItemControl" + id, PageViewID = "PageViewControl" + id, Text = "Tab"+id};

TabStripControl1.Items.Add(newTabStripItem);


MS Muralishankar Sundaram Syncfusion Team September 17, 2014 05:13 AM UTC

Hi Siang, 

Sorry about the inconvenience caused. 

We are able to reproduce the reported issue "Multipage is not maintaining the pageview state on the post back" with Tab control. we have logged the reported issue  as defect and working on it. In order to get fix, please contact us at Syncfusion Support or you may also open a support ticket by login in to direct trac account and mention this forum link for reference. 

Kindly let us know if you have further queries.  

Regards,

Muralishankar 


Loader.
Live Chat Icon For mobile
Up arrow icon