开发者

Keeping Tab open on postback

Hi i have some tabbing which works fine, however on postback the tabbing opens two at once. I was wondering how i can fix this issue. Here is the javascript i used;

$(".tab_content").hide(); 

    $("ul.tabs li:first").addClass("active").show(); 

    $(".tab_content:first").show();     

    $("ul.tabs li").click(function() {

        $("ul.tabs li").removeClass("active"); 

        $(this).addClass("active"); 

        $(".tab_content").hide(); 

        var activeTab = $(this).find("a").attr("href"); 

        $(activeTab).fadeIn(); 

        return false;

    });



    $('#texttab').click(function() {        

        $(".tab_content").addClass("heightone");    

        $(".tab_content").removeClass("heighttwo");

        $(".tab_content").removeClass("heightthree");

        $('#tabscontainer').addClass("hone");   

        $('#tabscontainer').removeClass("htwo");

        $('#tabscontainer').removeClass("hthree");  

    });



    $('#imagetab').click(function() {       

        $(".tab_content").addClass("heighttwo");    

        $(".tab_content").removeClass("heightone");

        $(".tab_content").removeClass("heightthree");

        $('#tabscontainer').addClass("htwo");   

        $('#tabscontainer').removeClass("hone");

        $('#tabscontainer').removeClass("hthree");

        $(".tab_container").css("height","650px");

    });

I tried using this piece of code to maintain it on postback however it does not work;

 $(function() {
        $("#tabscontainer").tabs({
            show: function() {
                var sel = $('#tabscontainer').tabs('option', 'selected');
                $("#<%= HFCurrTabIndex.ClientID %>").val(sel);
            },
            selected: <%= HFCurrTabIndex.Value %>
        });
    });

HTML

 <div id="tabscontainer"  class="hone">

                     <ul class="tabs"> 
                            <li><a href="#tab1" id="texttab">Text Update</a></li> 
                            <li><a href="#tab2" id="imagetab">Text &amp; Image Update</a></li> 
                    </ul> 

                     <div id="tab1" class="tab_content">

                    <div align="center"><asp:Button ID="lbtnUpdate" Text="Update" CssClass="bu开发者_如何学JAVAtton" OnClick="lbtnUpdate_Click" runat="server"></asp:Button></div>                        

                    </div> <!-- tab1 -->
                     <div id="tab2" class="tab_content">               

                    <span class="clear"></span>

                    <div align="center"><asp:Button ID="lbtnUpdateImage" Text="Update" CssClass="button" OnClick="lbtnUpdate_Click" runat="server"></asp:Button></div>                        
             </div> <!-- tab2 -->

         </div><!-- tabscontainer -->
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜