0

I have an asp.net page with 4 tab controls using the following html for each (changing their ID's for each one etc):

 <ul id="ulTabs">
    <li class="displayItem" id="liSummary" style="display: block"><a ref="#divSummary">
       <span style="font-weight: bold; color: #4b6c9e">Margin Analysis Summary</span>
    </a></li></ul>

The problem I have is that, on two of the tabs I have GridViews that open a new modal/screen. When this modal/screen is then closed, the page refreshes and the focus automatically goes back to the first tab regardless of which tab was selected when the modal/screen was opened.

Any ideas on how I can keep focus set to the current tab? I've tried a few solutions on different links but have found nothing so far.

Melanie
  • 584
  • 2
  • 11
  • 31

1 Answers1

0

Store the ID of the currently opened tab in a HiddenField when the tab opened is changed.

Then on load (after the refresh) open the tab represented by the ID stored in the hidden field.

I've done this with javascript and jquery when I've used jquery tabs in the past and it works really well. In fact, if it helps, here's how to do it with jquery. I'm sure you'll be able to adapt it for your own needs (or if you're doing it all in the code behind the page then it'll be even easier).

Community
  • 1
  • 1
Lloyd Powell
  • 18,270
  • 17
  • 87
  • 123