Remain bootstrap tab after postback c#

后端 未结 5 1947
再見小時候
再見小時候 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 20:03

    After quite a long time trying out the bootstrap tab.. i decided to change to jquery tab. In the first place, jquery tab also give the same problem i encounter in this situation.. but after much effort in looking for solution and trying out codes after codes.

    i managed to find a solution

    I'm really thankful to the person who provide this solution. In this solution, it uses sessionStorage (to me, its a new stuff that i never heard of) & the codes are

    $(document).ready(function () {
    var currentTabIndex = "0";
    
    $tab = $("#tabs").tabs({
         activate : function (e, ui) {
            currentTabIndex = ui.newTab.index().toString();
            sessionStorage.setItem('tab-index', currentTabIndex);
         }
    });
    
    if (sessionStorage.getItem('tab-index') != null) {
        currentTabIndex = sessionStorage.getItem('tab-index');
        console.log(currentTabIndex);
        $tab.tabs('option', 'active', currentTabIndex);
    }
    $('#btn-sub').on('click', function () {
        sessionStorage.setItem("tab-index", currentTabIndex);
        //window.location = "/Home/Index/";
    });
    });
    

提交回复
热议问题