locked
Asp.net Menu with css friendly adapter displays all levels static when populating control from code. RRS feed

  • Question

  • User657123739 posted

    I have a weird problem with the menu control, and I am not sure what is causing it. I'm using the css friendly adapters, which I suspect might be the cause.

    I populate the control dynamically in code along the lines of:

    Dim PageItem As New MenuItem
          With PageItem
               .NavigateUrl = "~/Default.aspx?p=" + CInt(drPage.Item("Id")).ToString + "&l=" + PreferredCulture
               .Value = CInt(drPage.Item("Id")).ToString
               .Text = CStr(drPage.Item("Name"))
               .ToolTip = CStr(drPage.Item("Title"))
               .Selectable = True
               If CStr
    (drPage.Item("Id")) = Request.Params("p") Then
                   .Selected = True          
              End If

    End With

    Me.MainNav.Items.Add(PageItem)

     

    I am adding child controls in the same fashion using ChildItems.Add

    I have an admin menu hierarchy containing pages in 2 levels that I would like to attach to the first menu item (Home) whenever the Admin logs on. This structure is created in the same way as above. However, when I add the menu items and try to add the top item to the first MainNav.Items(0).ChildItems.AddAt(0, AdminMenu), I end up with all the sublevels (under Home>Admin) being static: the 2 first levels, i,e. Home & Admin + SubLevel 1 are dynamic, while bottom level sub menus are displayed when the parent is. That is of course problematic, as the last level items are displayed on top of each other.

    Adding the same hierarchy to the top level (MainNav.Items.AddAt(0, AdminMenu) does not cause this problem. It is only when a fourth level is added that the menu goes weird. 

    Has anyone experienced a similar problem, or am I missing something here?

    J

    Thursday, September 27, 2007 2:03 PM

Answers

  • User657123739 posted

    Ok, I found that this issue has been addressed previously by Rassetti:  http://forums.asp.net/t/1140208.aspx. I added the css, and the control works as expected.

    - The hours spent on absolutely nothing! Sometimes I wish one could send the bill to Ms...

    A rather odd implementation of a server control, I think.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, October 1, 2007 6:11 AM

All replies

  • User657123739 posted

    Let me add that changing  

    StaticDisplayLevels="1" MaximumDynamicDisplayLevels="10"

    has no effect whatsoever.

    Am I really the only one who has this problem, and are there no one who can help shed some light here?

    Monday, October 1, 2007 5:08 AM
  • User657123739 posted

    Ok, I found that this issue has been addressed previously by Rassetti:  http://forums.asp.net/t/1140208.aspx. I added the css, and the control works as expected.

    - The hours spent on absolutely nothing! Sometimes I wish one could send the bill to Ms...

    A rather odd implementation of a server control, I think.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, October 1, 2007 6:11 AM