foreach (var Menus in @item.Descendants("menuItem")){
should probably be
@foreach (var Menus in item.Descendants("menuItem")){
The general rule of thumb is you need only an '@' when you are "out" of what I call "razor mode". This is usually when you're not in a @{ } block or when you have opened some HTML tag.. then razor is only expecting more HTML until you say @[HEREISSOMERAZOR] either with a @ { } block or as you're doign with inline @(somevariable.GetPropertyValue<...)
If you're already in "razor mode" then you don't need @ signs in fact it just tends to cause weird bugs e.g. for variables and the like.
Thanks for the answer! Both unfortunately did not give me a dropdown box. The second foreach should be without the @ because it errors on that. Thanks for trying to help out though!
Rereading your post - you expect a dropdown why? You're outputting html for a list so unless you have some JS that runs on the page or some CSS that styles it heavily it's always going to look like a sublist?!?
To make a dropdown you need to output some markup like:
Downdown menu
I made a menu for umbraco but I can't get the dropdown to work! Below is my code:
The dropdown code should start at
<ul class="nav subnav nav-list tree @(childIsActive ? "" : "collapse")">
but that doesn't seem to work.Below is a quick structure of how I want my page to be:
Help item 3 should have a dropdown which it doesn't have right now. What am I missing?+
Careful with your razor @ tags...
I think you need to correct
To
Also
should probably be
The general rule of thumb is you need only an '@' when you are "out" of what I call "razor mode". This is usually when you're not in a @{ } block or when you have opened some HTML tag.. then razor is only expecting more HTML until you say @[HEREISSOMERAZOR] either with a @ { } block or as you're doign with inline @(somevariable.GetPropertyValue<...)
If you're already in "razor mode" then you don't need @ signs in fact it just tends to cause weird bugs e.g. for variables and the like.
I hope that makes sense.
Steve
Thanks for the answer! Both unfortunately did not give me a dropdown box. The second foreach should be without the @ because it errors on that. Thanks for trying to help out though!
hi,
Rereading your post - you expect a dropdown why? You're outputting html for a list so unless you have some JS that runs on the page or some CSS that styles it heavily it's always going to look like a sublist?!?
To make a dropdown you need to output some markup like:
is working on a reply...