Remain bootstrap tab after postback c#

后端 未结 5 1949
再見小時候
再見小時候 2020-12-09 19:44

I am currently having problem retaining the bootstrap tab after my fileupload postback. The code is as follow



        
5条回答
  •  没有蜡笔的小新
    2020-12-09 19:50

    Well, I had this issue already and I solved it this way:

    1. Include a new HiddenField on your page and set its value to the first tab that need to be shown:

      
      
    2. On every click function you defined to alternate the tabs, set the HiddenField value to the actual tab clicked.

      document.getElementById('<%=hidTAB.ClientID %>').value = "image";
      
    3. On your jQuery document.ready function, use the HiddenField value to alternate to the last tab opened before the Postback.

      $(document).ready( function(){
          var tab = document.getElementById('<%= hidTAB.ClientID%>').value;
          $( '#myTab a[href="' + tab + '"]' ).tab( 'show' );
      });
      

    Here's the Bootstrap Tab Documentation and here's the jQuery Ready documentation

提交回复
热议问题