Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6227199
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:10:26+00:00 2026-05-24T09:10:26+00:00

I have the following Jquery which has 4 tabs which have 4 different searches

  • 0

I have the following Jquery which has 4 tabs which have 4 different searches

i.e.

1) Product Name Search
2) Supplier Search
etc

This is the Jquery

<script type="text/javascript">

$(document).ready(function() {

    //Default Action
    $(".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 rel attribute value to identify the active tab + content
        $(activeTab).fadeIn(); //Fade in the active content
        return false;
    });
});
</script>

And here is the tabs

        <ul class="tabs">
        <li><a href="#tab1">By Product Name</a></li>
        <li><a href="#tab2">By Supplier</a></li>
        <li><a href="#tab3">By EAN Code</a></li>
        <li><a href="#tab4">By IPU Code</a></li>
    </ul>
    <div id="tab1" class="tab-content">
        <asp:textbox id="searchProductName" runat="server"></asp:textBox> <asp:Button ID="btnProductSearch" runat="server" Text="Search Product Name"  CssClass="search" OnClick="ProductSearch_Click"  UseSubmitBehavior="true" CausesValidation="false" />
    </div>

    <div id="tab2" class="tab-content">
        <asp:textbox id="searchSupplierName" runat="server"></asp:textBox> <asp:Button ID="btnSupplierSearch" runat="server" Text="Search Supplier Name"  CssClass="search" OnClick="SupplierSearch_Click" />
    </div>

    <div id="tab3" class="tab-content">
       <asp:textbox id="searchEANCode" runat="server"></asp:textBox> <asp:Button ID="btnEANSearch" runat="server" Text="Search EAN Code"  CssClass="search" OnClick="EANSearch_Click" />
    </div>

    <div id="tab4" class="tab-content">
       <asp:textbox id="searchIPUCode" runat="server"></asp:textBox> <asp:Button ID="btnIPUSearch" runat="server" Text="Search IPU Code"  CssClass="search" OnClick="IPUSearch_Click" />
    </div>

Now the problem is everytime I perform a search i.e. in the second tab Supplier the page refreshes and the tabs gets reset to first tab.

In my onclick method, is there anyway I get set the tabs to display the second one when the page refreshes.

i.e.

    Protected Sub SupplierSearch_Click(ByVal sender As Object, ByVal e As EventArgs)
    ' Filter by Supplier
    If searchSupplierName.Text.Length > 0 Then
        srcProductListPerCustomer.FilterExpression = " (supplier_name like '%" + searchSupplierName.Text.ToString & "%')"
        productListTable.DataBind()
    End If
End Sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T09:10:26+00:00Added an answer on May 24, 2026 at 9:10 am

    What you can do is, add a public property to your page class say ActiveTabId, this property will contains the id of tab to set active, by default you can set it to say 1 i.e. show first tab on start… And when postback occurs from say Supplier tab set it to 2 and in your aspx page, within javascript code block call the .addClass() and .show() methods of appropriate tab…..

    In your code behind:

    Private _activeTabId As String
    
        Public Property ActiveTabId() As String
            Get
                Return _activeTabId
            End Get
            Set(ByVal value As String)
                _activeTabId = value
            End Set
        End Property
    
        Protected Sub form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles form1.Load
            Me._activeTabId = 1
        End Sub
    
    Protected Sub SupplierSearch_Click(ByVal sender As Object, ByVal e As EventArgs)
            'set tab id
            Me._activeTabId = 2
    
            ' Filter by Supplier
            If searchSupplierName.Text.Length > 0 Then
                srcProductListPerCustomer.FilterExpression = " (supplier_name like '%" + searchSupplierName.Text.ToString & "%')"
                productListTable.DataBind()
            End If
        End Sub
    

    and in your aspx page, within javascript code blocks:

    <script type="text/javascript">
            var activeTabId = '<%=ActiveTabId %>';
            $(document).ready(function() {      
                switch(activeTabId) {
                    case 1:
                        //for tab 1
                        $(".tab-content").hide(); //Hide all content
                        $("ul.tabs li:first").addClass("active").show(); //Activate first tab
                        $(".tab-content:first").show(); //Show first tab content
    
                    case n:
                        //for tab n
                        $(".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 rel attribute value to identify the active tab + content
                    $(activeTab).fadeIn(); //Fade in the active content
                    return false;
                });
            });
        </script>
    

    Between javascript code can be optimized but my version is just for the purpose of guideline…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have my front end script which has the following jQuery code: $.get(/backend/post.php, {
I have the following jQuery which I need adapting: $(document).ready(function(){ $(.rss-popup a).hover(function() { $(this).next(em).stop(true,
I have an application which uses phonegap and jquery mobile and it has tabs
I have the following jQuery which I want to output a list of images.
I have the following jQuery code which runs when I'm clicking an option in
Assuming I have the following two JQuery functions - The first, which works: $(#myLink_931).click(function
I have the following ListView in which I am using the JQuery UI sortable
I have the following JavaScript code which I like to convert to jQuery but
I have the following jquery which animates on hover: $('#footerNetwork').hover(function(){ $('#popupNetwork').animate({top:'-62px'},{queue:true,duration:500}); }, function(){ $('#popupNetwork').animate({top:'30px'},{queue:true,duration:500});
I have the following jQuery code: $(ul.menu li a).click(function() { $(ul.menu li a).removeClass(currentMenu); $(this).addClass(currentMenu);

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.