Welcome Guest Search | Active Topics | Sign In | Register

Upgrading code written for VB 2003 to VB 2005 Options
Corobori
Posted: Friday, May 2, 2008 8:38:25 AM
Rank: Member
Groups: Member

Joined: 7/12/2007
Posts: 24
Back a few year ago we used AspxLab menu control and I found the code shown below. I am trying to upgrade it using the current EO menu.

Back then we used the tag property to display or not the menu depending on the role of the current user. We would like to use now the AllowRoles property. I tried to change it but it doesn't work as expected.

Old code

Code: Visual Basic.NET
Private Sub DisplayRole(ByVal MenuItemCollection As AspxLab.WebControls.MenuItemCollection, ByVal srole As String)

        Dim mn As MenuItem
        For Each mn In MenuItemCollection
            If mn.Tag Is Nothing Then
            Else
                If (mn.Tag.Length > 0) Then

                    If (mn.Tag.IndexOf(srole) >= 0) Then
                        mn.Visible = True
                    Else
                        mn.Visible = False
                    End If
                    If (mn.Visible And mn.SubItems.Count > 0) Then

                        DisplayRole(mn.SubItems, srole)
                    End If
                End If
            End If
        Next
    End Sub


New code (not working)

Code: Visual Basic.NET
Private Sub DisableItems( _
        ByVal items As EO.Web.MenuItemCollection, _
        ByVal srole As String)

        Dim item As EO.Web.MenuItem
        For Each item In items
            If InStr(item.AllowRoles, srole) <> 0 Then
                item.Visible = True
            Else
                item.Visible = False
            End If
            DisableItems(item.SubMenu.Items, srole)
        Next

    End Sub
eo_support
Posted: Friday, May 2, 2008 11:02:57 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,218
Hi,

"Tag" has been renamed to "Value". So you can use "Value" directly as you were using "Tag". AllowRoles on the other hand automatically disable/hide items based on the current logged in user, so that may not be what you wanted.

Thanks
Corobori
Posted: Friday, May 2, 2008 11:31:28 AM
Rank: Member
Groups: Member

Joined: 7/12/2007
Posts: 24
Did the trick, thanks


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.