title: Using "TabContainer" and "TabPanel" Ajax Toolkits
body: <p>I have a few tabs on a page and it always defaults to the first tab , but when a link is clicked i want it to select a diferent tab using javascript. How can I select the tab with Javascript?</p>
  
  <p>Right now, because the default is selecting the first tab, javascript throws an error that either pnlTab2 is not visible or does not exist. But if I manually click on the tab and then on the link it focuses on that tab correctly?</p>
  
  <p>I am new in C# and Javascript, can anyone please help me?, how can I select the second tab using javascript and then focus so that it does not give me error?</p>
  
  <p>Thank you</p>
  
  <pre><code> function DoFocus() {
      var pnlTab1 = document.getElementById('&lt;%=pnlTab1.ClientID%&gt;');
      var pnlTab2 = document.getElementById('&lt;%=pnlTab2.ClientID%&gt;');
  
      if (pnlTab2 != null ) {
  
          //I WANT TO SELECT THE TAB HERE
          document.getElementById('&lt;%=pnlCustomerReviews.ClientID%&gt;').focus();
      }
      else {
           //OR SELECT THIS ONE
          document.getElementById('&lt;%=pnlTab2.ClientID%&gt;').focus();
      }
           return false;
  }
  </code></pre>
  
  <p>  </p>
  
  <pre><code>&lt;asp:UpdatePanel ID="UpdatePnl" runat="server" UpdateMode="Conditional"&gt;
          &lt;ContentTemplate&gt;     
              &lt;ajaxToolKit:TabContainer runat="server" id="myTabs" CssClass="CustomTabStyle"&gt;
              &lt;ajaxToolKit:TabPanel ID="pnlTab1" runat="server" HeaderText="Tab 1"&gt;                                                  
              &lt;ContentTemplate&gt; 
                  &lt;table&gt; 
                      &lt;tr&gt;                           
                          &lt;td&gt;                 
                              &lt;div class="Tab1"&gt;                     
                                  &lt;asp:Label ID="lblPnl1" runat="server"&gt;&lt;/asp:Label&gt;                                                   
                              &lt;/div&gt;                              
                          &lt;/td&gt;
                      &lt;/tr&gt;   
                  &lt;/table&gt; 
              &lt;/ContentTemplate&gt;             
              &lt;/ajaxToolKit:TabPanel&gt;
  
              &lt;ajaxToolKit:TabPanel ID="pnlTab2" runat="server" HeaderText="Tab2"&gt;               
              &lt;ContentTemplate&gt;              
                  &lt;table&gt;
                      &lt;tr&gt;
                          &lt;td&gt;
                              &lt;div class="Tab2"&gt;                     
                                  &lt;asp:Label ID="lblPnl2" runat="server"&gt;&lt;/asp:Label&gt;                       
                              &lt;/div&gt;
                          &lt;/td&gt;
                      &lt;/tr&gt;
                  &lt;/table&gt;
              &lt;/ContentTemplate&gt;
             &lt;/ajaxToolKit:TabPanel&gt;
   &lt;/ajaxToolKit:TabContainer&gt;
      &lt;/ContentTemplate&gt;
  &lt;/asp:UpdatePanel&gt;
  </code></pre>