Tweaking AJAX Tab Panel Preservation

  • Thread starter Thread starter Plateriot
  • Start date Start date
P

Plateriot

I have several pages that have 3 tabs.
One of the desired effects is to preserve whatever tab the user may have
selected from page-to-page.
So I use the following Client-Side script to remember a Tab that the user
selects. I can then preserve it and use the number to switch to the same tab
on another page:

<script type="text/javascript">
function PanelClick(sender, e) {
}

function ActiveTabChanged(sender, e) {
// use the client side active tab changed
// event to trigger a callback thereby
// triggering the server side event.
__doPostBack('<%= tabs.ClientID %>',
sender.get_activeTab().get_headerText());
}

</script>

I combine that client-side script with this code-behind:

Protected Sub Tabs_ActiveTabChanged(ByVal sender As Object, ByVal e As
System.EventArgs)
Session("ssTab") = Me.Tabs.ActiveTabIndex
End Sub


and then in the Load_Event of the page in question:

'return whatever tab the user has selected
Me.Tabs.ActiveTabIndex = Session("ssTab")


The problem with this, particularly if the page is data intensive, is that
there is a significant delay before the client-side script kicks off and does
the 'post-back'
so, for example, the user sees the page presented when they click the tab,
but a couple of seconds later - it does the postback (just so that the server
side can record whatever tab the user selected)

How can I tweak this to get the best desired outcome -
which is:
1) preserve the tab index when the user clicks it
2) use that index on other pages - but WITHOUT a tacky postback mid-viewing
 
Back
Top