title: How should I store the current position of tabs during a postback?
body: <p>I am storing the current position of tab using ctl0 . is this the right method for storing the current tab value. I read some where use client id bcz it will mismatch during run time. how i am get client id. i am storing using hidden field.What am i doing wrong
  <strong>this my HTML</strong></p>
  
  <pre><code>&lt;ul class='tabs'&gt;
      &lt;li&gt;&lt;a href='#tab1'&gt;Tab 1&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href='#tab2'&gt;Tab 2&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href='#tab3'&gt;Tab 3&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
    &lt;div id='tab1'&gt;
      &lt;p&gt;Hi, this is the first tab.&lt;/p&gt;
    &lt;/div&gt;
    &lt;div id='tab2'&gt;
      &lt;p&gt;This is the 2nd tab.&lt;/p&gt;
    &lt;/div&gt;
    &lt;div id='tab3'&gt;
      &lt;p&gt;And this is the 3rd tab.&lt;/p&gt;
    &lt;/div&gt;
  </code></pre>
  
  <p><strong>Script</strong></p>
  
  <pre><code>$(document).ready(function () {
  
          $('ul.tabs').each(function () {
              // For each set of tabs, we want to keep track of
              // which tab is active and it's associated content
              var $active, $content, $links = $(this).find('a');
  
  
              // If the location.hash matches one of the links, use that as the active tab.
              // If no match is found, use the first link as the initial active tab.
              if ($('#_ctl0_hdnCurrentTabSelection').val() == "") {
                  $('#_ctl0_hdnCurrentTabSelection').val(location.hash)
              }
  
              $active = $($links.filter('[href="' + $('#_ctl0_hdnCurrentTabSelection').val() + '"]')[0] || $links[0]);
              $active.addClass('active');
              $content = $($active.attr('href'));
  
              window.location.href = window.location.href.toString() + $active.attr('href');
  
  
              // Hide the remaining content
              $links.not($active).each(function () {
                  $($(this).attr('href')).hide();
              });
  
  
              // Bind the click event handler
              $(this).on('click', 'a', function (e) {
  
                  // Make the old tab inactive.
                  $active.removeClass('active');
                  //window.location.href = window.location.href.toString().replace($active.attr('href'), '');
                  $content.hide();
  
                  // Update the variables with the new link and content
                  $active = $(this);
                  $('#_ctl0_hdnCurrentTabSelection').val($active.attr("href"))
                  $content = $($(this).attr('href'));
  
                  window.location.href = window.location.href.toString().split('#')[0] + $active.attr('href');
  
                  // Make the tab active.
                  $active.addClass('active');
                  $content.show();
  
  
  
                  // Prevent the anchor's default click action
                  e.preventDefault();
              });
          });
  </code></pre>
  
  <p><strong>vb code</strong></p>
  
  <pre><code> hdnCurrentTabSelection.Value = Request.Form(hdnCurrentTabSelection.UniqueID)
  </code></pre>
  
  <p>*<strong>aspx code</strong></p>
  
  <pre><code> &lt;input type="hidden" ID="hdnCurrentTabSelection"  runat="server" /&gt;
  </code></pre>