ASP.NET 4 Menu Control levelsubmenustyles and LevelMenuItemStyles

Discussion in 'ASP .Net Web Controls' started by Drew, Jul 3, 2010.

  1. Drew

    Drew Guest

    I upgraded to the ASP.NET 4.0 platform due to a number of features and have
    hit a number of very basic problems. I've seen only a couple of references
    to these on the internet, others were unable to reproduce them.
    Unfortunately, I can do nothing but reproduce them.

    --levelsubmenustyles
    First of all the asp.net 4.0 menu control works fine in table mode. I wanted
    it to use list mode due to the CSS styling issues in table form and have
    unfortunately gotten nowhere. For example, when I use the code at the top of
    this article.
    http://msdn.microsoft.com/en-us/library/ms366731.aspx
    It won't render. I get the exception
    Unable to cast object of type 'System.Web.UI.WebControls.SubMenuStyle'
    to type 'System.Web.UI.WebControls.MenuItemStyle'
    and no, reverting to 3.5 style rendering is not an option. I've tried
    manually setting the List render mode, no luck. set the same mode to render
    as a table and it works.

    --LevelMenuItemStyles
    While the LevelSubmenuStyles collection throws a casting exception, the
    LevelMenuItemStyles seems to work, kinda. At least it renders, but it
    ignores my first level. So if I specify
    <LevelMenuItemStyles>
    <asp:MenuItemStyle CssClass="Level1Style" />
    <asp:MenuItemStyle CssClass="Level2Style" />
    <asp:MenuItemStyle CssClass="Level3Style" />
    </LevelMenuItemStyles>
    It will never use Level1Style anywhere in my menu. Instead, the top level UL
    tag will render as
    <ul class="level1">
    and then the subsequent <li> tags will have class="level2 Level2Style etc"
    as expected.



    I'd love to know why the CSS styling in my menus are so broken. Not sure if
    there's some environmental issue that's causing this because I'd expect much
    more outrage in the community if this was widespread. I'm running this as a
    file system web site on windows 7 ultimate 64bit with Visual Web Developer
    2010 Express.

    Thanks in advance for your help.
     
    Drew, Jul 3, 2010
    #1
    1. Advertising

  2. Drew

    Drew Guest

    I have an update to the second item.

    --LevelMenuItemStyles
    while you may specify multiple LevelMenuItemStyles, if you have the
    ShowStartingNode attribute set to "false" on the site map datasource, then
    it will also skip the first level style. this is a departure from the way
    the previous control worked and isn't intuitive (or logical).


    "Drew" wrote in message news:#...

    I upgraded to the ASP.NET 4.0 platform due to a number of features and have
    hit a number of very basic problems. I've seen only a couple of references
    to these on the internet, others were unable to reproduce them.
    Unfortunately, I can do nothing but reproduce them.

    --levelsubmenustyles
    First of all the asp.net 4.0 menu control works fine in table mode. I wanted
    it to use list mode due to the CSS styling issues in table form and have
    unfortunately gotten nowhere. For example, when I use the code at the top of
    this article.
    http://msdn.microsoft.com/en-us/library/ms366731.aspx
    It won't render. I get the exception
    Unable to cast object of type 'System.Web.UI.WebControls.SubMenuStyle'
    to type 'System.Web.UI.WebControls.MenuItemStyle'
    and no, reverting to 3.5 style rendering is not an option. I've tried
    manually setting the List render mode, no luck. set the same mode to render
    as a table and it works.

    --LevelMenuItemStyles
    While the LevelSubmenuStyles collection throws a casting exception, the
    LevelMenuItemStyles seems to work, kinda. At least it renders, but it
    ignores my first level. So if I specify
    <LevelMenuItemStyles>
    <asp:MenuItemStyle CssClass="Level1Style" />
    <asp:MenuItemStyle CssClass="Level2Style" />
    <asp:MenuItemStyle CssClass="Level3Style" />
    </LevelMenuItemStyles>
    It will never use Level1Style anywhere in my menu. Instead, the top level UL
    tag will render as
    <ul class="level1">
    and then the subsequent <li> tags will have class="level2 Level2Style etc"
    as expected.



    I'd love to know why the CSS styling in my menus are so broken. Not sure if
    there's some environmental issue that's causing this because I'd expect much
    more outrage in the community if this was widespread. I'm running this as a
    file system web site on windows 7 ultimate 64bit with Visual Web Developer
    2010 Express.

    Thanks in advance for your help.
     
    Drew, Jul 4, 2010
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Vilmar
    Replies:
    0
    Views:
    472
    Vilmar
    May 27, 2004
  2. itzikkl
    Replies:
    0
    Views:
    5,775
    itzikkl
    Mar 27, 2005
  3. Replies:
    0
    Views:
    1,446
  4. hal

    disable menu items for the asp menu control

    hal, Sep 6, 2006, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    197
  5. Jerry C

    ASP:Menu control Dropdowns show above Main Menu

    Jerry C, Feb 21, 2007, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    226
    Walter Wang [MSFT]
    Feb 26, 2007
Loading...

Share This Page