Hidden Field Retaining Value After Second Postback jQuery Tab

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • spoonybard
    New Member
    • Nov 2007
    • 19

    Hidden Field Retaining Value After Second Postback jQuery Tab

    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:

    Code:
            Dim script As New StringBuilder()
    
            'Create the jQuery tab control
            script.Append("$('#" & Me.MyContainer.ClientID & "').tabs();")
    
            'Tab change handler - stores the selected tab's client ID in the hidden field.
            script.Append("$('#" & Me.MyContainer.ClientID & "').bind( 'tabsselect', function(event, ui) {")
            script.Append("jQuery(""#" & Me.hidSelectedTab.ClientID & """).val(ui.panel.id);")
            script.Append("});")
    
            'Force tab selection if hidden control has a value
            If Not Me.hidSelectedTab Is Nothing AndAlso Not String.IsNullOrEmpty(Me.hidSelectedTab.Value) Then
                script.Append("$('#" & Me.MyContainer.ClientID & "').tabs('select', '" & Me.hidSelectedTab.Value & "');")
            End If
    
            'Register the script
    Due to the restrictions of our web application, we cannot use the jQuery Cookie method for maintaining the selected tab.

    Thanks!
Working...