Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
240
Ingragistics WebTab Control
posted

Hi,

How to add tabs dynamically in Ingragistics WebTab Control?  

Example:

  <ig:WebTab ID="WebTab1" runat="server" Height="189px" Width="271px" 
        ForeColor="#FF33CC" SelectedIndex="1">
        <tabs>
            <ig:ContentTabItem runat="server" Text="Tab 1">
                <Template>
                    <asp:Button ID="btnCreateNewTab" runat="server" Text="Create New Tab" />
                </Template>
            </ig:ContentTabItem>
        
        </tabs>
        <TabItemCssClasses SelectedCssClass="tabText" />
    </ig:WebTab>

On click of "btnCreateNewTab" needs add a new tab.

Thanks in advance
  • 24497
    Verified Answer
    posted

    Hi Chinna,

    To create new tab item dynamically, you need to create new ContentTabItem and add it to WebTab.Tabs. That new tab item will persist between postbacks. If you use ContentUrl or UserControlUrl for that new tab, then that will persist as well. Though, if you need to create dynamic child controls, then those child controls will not persist, because .NET framework may support only ViewStates of dynamic controls, but not recreation of those controls.
    If you need dynamic controls, then application needs quite complex logic, which will track all once created child controls for each specific new tab, recreate those child controls in each single session, ensure exactly same IDs and add them to corresponding tab-items. In this case those child controls and their ViewStates will persist between postbacks.

    Below is an example for new tab with ContentUrl:

    protected void btnCreateNewTab_Click(object sender, EventArgs e)
    {
      Infragistics.Web.UI.LayoutControls.ContentTabItem tab = new Infragistics.Web.UI.LayoutControls.ContentTabItem();
     
    this.WebTab1.Tabs.Add(tab);
     
    tab.Text = "New Tab";
     
    tab.ContentUrl = http://es.infragistics.com;
     
    //TextBox tb = new TextBox();
     
    //tb.ID = "UniqueIdForTextBoxOnNewTab";
     
    //tab.Controls.Add(tb);
    }