By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
462,160 Members | 582 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 462,160 IT Pros & Developers. It's quick & easy.

Hidden Field Retaining Value After Second Postback jQuery Tab

P: 19
I have an ASP.Net 3.5 VB web application that has a jQuery UI Tab control on it. I am trying to maintain the selected tab through postbacks so I can reselect that tab when the page reloads. In order to maintain the value between postbacks, I am using a Hidden Field.

The issue I am running into is that on the first postback, the Hidden Field does not maintain the value I am giving it. However, from the second postback on, it properly manages the selected tab value.

The following is the jQuery code that I am using. It is being built in the Code Behind OnPreRender and the Hidden Field is declared in the Code Behind:

Expand|Select|Wrap|Line Numbers
  1.         Dim script As New StringBuilder()
  2.  
  3.         'Create the jQuery tab control
  4.         script.Append("$('#" & Me.MyContainer.ClientID & "').tabs();")
  5.  
  6.         'Tab change handler - stores the selected tab's client ID in the hidden field.
  7.         script.Append("$('#" & Me.MyContainer.ClientID & "').bind( 'tabsselect', function(event, ui) {")
  8.         script.Append("jQuery(""#" & Me.hidSelectedTab.ClientID & """).val(ui.panel.id);")
  9.         script.Append("});")
  10.  
  11.         'Force tab selection if hidden control has a value
  12.         If Not Me.hidSelectedTab Is Nothing AndAlso Not String.IsNullOrEmpty(Me.hidSelectedTab.Value) Then
  13.             script.Append("$('#" & Me.MyContainer.ClientID & "').tabs('select', '" & Me.hidSelectedTab.Value & "');")
  14.         End If
  15.  
  16.         'Register the script
  17.  
Due to the restrictions of our web application, we cannot use the jQuery Cookie method for maintaining the selected tab.

Thanks!
May 3 '10 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.