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
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
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
|
Rank: Member Groups: Member
Joined: 7/12/2007 Posts: 24
|
Did the trick, thanks
|