Click here to Skip to main content
15,892,746 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
Dear Sir,

I have use two tab in my Index form. News and OrdersBagged forms. if i click the link in ordersbagged , then the page will go to OrdersDetails page. Then click Back button in OrdersDetails it will go to Index page the default tab is News selected , but i want to select Orderbagged tab. please help me..


My first tab id is tab1 and Second tab id is tab2

What I have tried:

JavaScript
<script type="text/javascript">
    $(document).ready(function () {
        $("#tab2").trigger('click');
    });
</script>
Posted
Updated 9-Aug-16 1:15am
v2

1 solution

1. Put a hidden field on your form give it any Id
e.g. id="selectedTabHiddenField"

2. On tab click, set the value of "selectedTabHiddenField" to same as Id of selected tab.
e.g. $("selectedTabHiddenField").val("tab2");

3. Collect the value of the hidden field on server side and store it to Session variable
e.g. Session["selectedTab"] = selectedTabHiddenField.Value;

4. On page load, check if Session variable in step 3 contains value, if so set selectedTabHiddenField value to session value.
 
Share this answer
 
Comments
Thiyagu Arockiasamy 9-Aug-16 7:21am    
Thanks a lot. i got output....
njammy 9-Aug-16 8:58am    
ok...please mark as answer if this helped. And if possible put some example of your solution for helping others.
Karthik_Mahalingam 9-Aug-16 10:47am    
5
Thiyagu Arockiasamy 9-Aug-16 11:13am    
5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900