Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
80
Programatically Select Item
posted

I'm trying out the WebExplorerBar as a replacement for the old UltraWebListBar, which failed to support a few browsers (chrome, safari, pc&mac). Naturally, I want the WebExplorerBar to behave in a similar manner to the UltraWebListBar (while being crossbrowser compatible), but so far I haven't had much luck replacating the same behaviour.

I'm using a masterpage, and don't want to use an IFrame/target. The way it should work is that, on page postback, I programatically tell the WebExplorerBar which item is selected, and it will open that group, and select that item.

First, it was rather difficult to specify which item I wanted. With UltraWebListBar, I could specify the selecteditem by:

NavBar.SelectedItem = NavBar.Groups.FromKey(groupkey).Items.FromKey(itemkey) 

Which no longer works, since "SelectedItem" is readonly, and there are no longer item/group collection keys. The only thing I could do was iterate through the groups and items until I found the NavigateURL that matched the current URL, and set that item's selected property to True:

       For Each grp In WebExplorerBar1.Groups
            Dim grpSelected As Boolean = False
            For Each itm As Infragistics.Web.UI.NavigationControls.ExplorerBarItem In grp.Items
                If Request.CurrentExecutionFilePath() = ResolveUrl(itm.NavigateUrl) Then
                    itm.Selected = True
                    grpSelected = True
                    Exit For
                End If
            Next
            If grpSelected Then
                grp.Expanded = True
                Exit For
            End If
        Next

This code executes but apparently does nothing, or is ignored. Upon postback, the WebExplorerBar returns to its initial state, with the first group expanded and nothing visibly selected.

Changing the ViewState on the WebExplorerBar did not help.

What am I doing wrong?

Thanks.