Mega Menu doesn't work in VB.Net

5 posts, 0 answers
  1. Eugene
    Eugene avatar
    3 posts
    Member since:
    May 2013

    Posted 14 May 2013 Link to this post



    Hi guys,

    after  translation your Mega Menu demo C# code in VB.Net   
    it doesn't work properly, looks like function   item.Items.Clear()  erases child records in menu,
    if I comment that function - child records are kept in menu with wrong alignments,


    Best regards
    p.s  my source code is below:


    Partial Class _Default
        Inherits System.Web.UI.Page

        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load


            If Not Page.IsPostBack Then
                RadMenu1.LoadContentFile("Menu.xml")
                RadMenu1.DataBind()
            End If
        End Sub

        Protected Sub RadMenu1_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadMenu1.DataBound

            Dim menu As Telerik.Web.UI.RadMenu = CType(sender, Telerik.Web.UI.RadMenu)

            For Each item As Telerik.Web.UI.RadMenuItem In menu.Items
                Dim sm As Telerik.Web.UI.RadSiteMap = New Telerik.Web.UI.RadSiteMap
                PopulateSiteMap(sm, Nothing, item)
                Dim rootLevelSetting As Telerik.Web.UI.SiteMapLevelSetting = New Telerik.Web.UI.SiteMapLevelSetting(0)
                rootLevelSetting.ListLayout.RepeatColumns = 5
                rootLevelSetting.ListLayout.RepeatDirection = Telerik.Web.UI.SiteMapRepeatDirection.Vertical
                sm.LevelSettings.Add(rootLevelSetting)

                item.Items.Clear()

                Dim childItem As Telerik.Web.UI.RadMenuItem = New Telerik.Web.UI.RadMenuItem
                Dim catWrapper As Panel = New Panel
                catWrapper.Width = Unit.Pixel(800)
                catWrapper.Controls.Add(sm)


                If ((Not (item.Attributes("ImagePosition")) Is Nothing) _
                AndAlso (Not (item.Attributes("GroupImageUrl")) Is Nothing)) Then
                    Dim img1 As Image = New Image
                    img1.ImageUrl = item.Attributes("GroupImageUrl")
                    catWrapper.Controls.AddAt(Integer.Parse(item.Attributes("ImagePosition")), img1)
                End If

                childItem.Controls.Add(catWrapper)
                item.Items.Add(childItem)

            Next


        End Sub

        Private Shared Sub PopulateSiteMap(ByVal sm As Telerik.Web.UI.RadSiteMap, ByVal node As Telerik.Web.UI.RadSiteMapNode, ByVal item As Telerik.Web.UI.RadMenuItem)

            If (node Is Nothing) Then
                For Each child As Telerik.Web.UI.RadMenuItem In item.Items
                    '' sm.Nodes.Add(New Telerik.Web.UI.RadSiteMapNode(child.Text, child.NavigateUrl))

                    node = New Telerik.Web.UI.RadSiteMapNode(child.Text, child.NavigateUrl)
                    sm.Nodes.Add(node)
                    If (child.Items.Count > 0) Then
                        PopulateSiteMap(sm, node, child)
                    End If
                Next
            Else
                For Each child As Telerik.Web.UI.RadMenuItem In item.Items
                    node.Nodes.Add(New Telerik.Web.UI.RadSiteMapNode(child.Text, child.NavigateUrl))
                    If (child.Items.Count > 0) Then
                        PopulateSiteMap(sm, node, child)
                    End If
                Next
            End If

        End Sub
    End Class

  2. Eugene
    Eugene avatar
    3 posts
    Member since:
    May 2013

    Posted 15 May 2013 Link to this post

    Dear Telerik Team/Admin/Master !

    could you answer my question about Mega Menu running under VB.Net problem please, 

    what's wrong?

    Best regards
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Kate
    Admin
    Kate avatar
    1898 posts

    Posted 21 May 2013 Link to this post

    Hi Eugene,

    Can you please clarify if you refer to our MegaDropDown menu described here? If that is the case please note that in this demo we do not use any code behind and there is no need to convert the code and consequently clear the menu items.

    All the best,
    Kate
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  5. Eugene
    Eugene avatar
    3 posts
    Member since:
    May 2013

    Posted 23 May 2013 Link to this post

    Dear Kate,

    I got C# source code from that link:

    http://www.telerik.com/support/kb/aspnet-ajax/menu/mega-drop-down-menu-bind-to-xml-datasource.aspx

    Best regards

    Eugene


  6. Kate
    Admin
    Kate avatar
    1898 posts

    Posted 28 May 2013 Link to this post

    Hi Eugene,

    I have just updated the KB so that it includes both C# and VB version of the code. I also tested it and it works as expected from my side.

    Regards,
    Kate
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017