ASP.NET 4 Menu Control levelsubmenustyles and LevelMenuItemStyles

D

Drew

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.
 
D

Drew

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
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top