title: How to add tabPanels to tabContainer on button click
body: <p>I have a tab container within an update panel. I'd like to add generated tabs to that container on a button click. The tabs get added. Once, the next time the button's clicked the previous tab is lost and a new one replaces it. I want to keep the tabs if possible. These tabs will later be filled with controls based on which button is clicked.</p>
  
  <p>I've found many posts suggesting that the tabs have to be re-created on PostBack but it's not working. I don't think I know how to do it either. </p>
  
  <p>My current aspx file.</p>
  
  
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head runat="server"&gt;
      &lt;title&gt;&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form id="form1" runat="server"&gt;
      &lt;asp:ScriptManager ID="ScriptManager1" runat="server" ViewStateMode="Enabled"&gt;
      &lt;/asp:ScriptManager&gt;
  
      &lt;asp:Button ID="Button1" runat="server" Text="Add Tab" /&gt;
      &lt;div&gt;
          &lt;asp:UpdatePanel ID="UpdatePanel1" runat="server"&gt;
              &lt;ContentTemplate&gt;
                  &lt;ajaxToolkit:TabContainer ID="TabContainer1" runat="server" 
                      ViewStateMode="Enabled"&gt;
                  &lt;/ajaxToolkit:TabContainer&gt;
                  &lt;br /&gt;
                  &lt;asp:Label ID="Label1" runat="server" Text="Label"&gt;&lt;/asp:Label&gt;
              &lt;/ContentTemplate&gt;
              &lt;Triggers&gt;
                  &lt;asp:AsyncPostBackTrigger ControlID="Button1" /&gt;
              &lt;/Triggers&gt;
          &lt;/asp:UpdatePanel&gt;
  
      &lt;/div&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Here is the code-behind so far.</p>
  
  <pre><code>Imports AjaxControlToolkit
  
  Public Class WebForm1
      Inherits System.Web.UI.Page
  
      Private Sub WebForm1_Load(sender As Object, e As System.EventArgs) Handles Me.Load
  
      End Sub
  
      Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
          Dim newTab As TabPanel = New TabPanel
          Dim rand As New Random
          Dim exampleID As String = rand.Next(1000).ToString
          newTab.ID = exampleID
          newTab.HeaderText = exampleID
          newTab.Controls.Add(New LiteralControl(exampleID))
          TabContainer1.Tabs.Add(newTab)
          Label1.Text = Label1.Text + "&lt;br /&gt;" + "Added tab " + newTab.ID.ToString 'Just here for output.
      End Sub
  
  End Class
  </code></pre>
  
  <p>I'm sure the current open tabs have to be stored somewhere and re-created on the update panel's postback but like I said. Where do I put that code and how is it stored?</p>
  
  <p>Any help would be much appreciated! Thanks!</p>