This is a migrated thread and some comments may be shown as answers.

Dynamic Menu Creation with hierarchical access

3 Answers 108 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Cécil
Top achievements
Rank 2
Cécil asked on 10 Nov 2008, 12:20 PM
Hi
I would like to know if it are using the radmenu within the code below, because through this code that I set who has access to it.

Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Page.IsPostBack Then

            Dim dtMenuItems As New DataSet
            Dim erro As Boolean = False
            Dim mensagem As String = ""
            Dim obj As New clsSistemaVistoria.Menu

            dtMenuItems = obj.Buscar(erro, mensagem, 2, "", Session("ID_Usuario"))

            For Each drMenuItem As Data.DataRow In dtMenuItems.Tables(0).Rows

                If drMenuItem("ID_Menu").Equals(drMenuItem("ID_MenuPai")) Then
                    Dim mnuMenuItem As New MenuItem
                    mnuMenuItem.Value = drMenuItem("ID_Menu").ToString
                    mnuMenuItem.Text = drMenuItem("NM_Menu").ToString
                    If drMenuItem("Url_Menu").ToString.Trim <> "" Then
                        mnuMenuItem.NavigateUrl = drMenuItem("Url_Menu").ToString & "?Autorizacao=" & drMenuItem("TP_Acesso").ToString
                    Else
                        mnuMenuItem.Selectable = False
                    End If
                    mnuPrincipal.Items.Add(mnuMenuItem)

                    AddMenuItem(mnuMenuItem, dtMenuItems.Tables(0))
                End If
            Next
        End If
 End Sub

    Private Sub AddMenuItem(ByRef mnuMenuItem As MenuItem, ByVal dtMenuItems As Data.DataTable)

        For Each drMenuItem As Data.DataRow In dtMenuItems.Rows
            If drMenuItem("ID_MenuPai").ToString.Equals(mnuMenuItem.Value) AndAlso _
            Not drMenuItem("ID_Menu").Equals(drMenuItem("ID_MenuPai")) Then
                Dim mnuNewMenuItem As New MenuItem
                mnuNewMenuItem.Value = drMenuItem("ID_Menu").ToString
                mnuNewMenuItem.Text = drMenuItem("NM_Menu").ToString
                If drMenuItem("Url_Menu").ToString.Trim <> "" Then
                    mnuNewMenuItem.NavigateUrl = drMenuItem("Url_Menu").ToString & "?Autorizacao=" & drMenuItem("TP_Acesso").ToString
                Else
                    mnuMenuItem.Selectable = False
                End If
                mnuMenuItem.ChildItems.Add(mnuNewMenuItem)

                AddMenuItem(mnuNewMenuItem, dtMenuItems)
            End If
        Next

        For Each drMenuItem As Data.DataRow In dtMenuItems.Rows

        Next

    End Sub

3 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 10 Nov 2008, 04:55 PM
Hi Cécil,

Unfortunately I couldn't understand your question. What are you trying to achieve? What are the problems your are facing?

From your code it seems that you are using the built-in ASP.NET menu. Is this the case? Are you trying to migrate from it to RadMenu?

All the best,
Albert
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Cécil
Top achievements
Rank 2
answered on 10 Nov 2008, 05:48 PM
The code above is responsible for assembling the menu that is currently in the system. I would like to migrate this menu to radmenu without having to change the way they access the database and defines the hierarchy of access.
Is that possible?
0
Accepted
Atanas Korchev
Telerik team
answered on 10 Nov 2008, 05:54 PM
Hi Cécil,

In that case you need to do the following:
  1. Change the MenuItem type to RadMenuItem (it is defined in the Telerik.Web.UI namespace)
  2. Change the ChildItems property to "Items"
  3. Avoid setting the Selectable property to false as RadMenuItem does not have it.
I hope this helps,
Albert
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Menu
Asked by
Cécil
Top achievements
Rank 2
Answers by
Atanas Korchev
Telerik team
Cécil
Top achievements
Rank 2
Share this question
or