[RESOLVED]Jquery Tabs

I have two tabs and a jquery function to handle it as shown below

<ul class="tabs">
        <li id="tabBuy1" runat="server"><a href="#tab1">For Buy</a></li>
        <li id="tabSale1" runat="server"><a href="#tab2">For Sale</a></li>

 <script type="text/javascript">
                $(document).ready(function () {

                    //When page loads...
                    $(".tab_content").hide(); //Hide all content
                    $("ul.tabs li:first").addClass("active").show(); //Activate first tab
                    $(".tab_content:first").show(); //Show first tab content

                    //On Click Event
                    $("ul.tabs li").click(function () {

                        $("ul.tabs li").removeClass("active"); //Remove any "active" class
                        $(this).addClass("active"); //Add "active" class to selected tab
                        $(".tab_content").hide(); //Hide all tab content

                        var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
                        $(activeTab).fadeIn(); //Fade in the active ID content
                        return false;



I have type in session variable .

I want if type is 1 the buy is selected else sale tab is selected

How to to it

I am not sure about above code but try adding default CSS styles for jquery tabs.

check example:


Access C# variables in javascript/jquery - http://www.intstrings.com/ramivemula/articles/access-code-behind-variables-in-aspx-and-javascript/ 

using that you can get to know session string in clientside, then you can set focus for jquery tab….



Maybe the mistake is in the counter. I’m pretty sure that in this cases the counter starts in 0. Maybe is for that reason you get selected one tab but not the one that you want.



Oscar Gómez

Engineer at PSL



You can save your selection in a hidden field and resigne once reloaded-


Leave a Reply