How to: Add unique CSS class to MenuItems [submenu links]?

Topics: General, Writing modules
Sep 1, 2014 at 12:08 AM
Hey guys, I’ve successfully added an incremental class to ‘Menu.cshtml’:
    if (items.Any()) {
        items[items.Count - 1].Classes.Add("last");
        // My Code:
        for (var i = 0; i <= items.Count - 1; i++) {
            items[i].Classes.Add("pos" + i);
So that I can style the menu items individually; works as expected. But now I wish to do the same for any Menu Items that have children i.e. I wish to style ‘MenuItem.cshtml’:
            if (items.Any())
                <ul class="dropdown-menu"> @*CHANGE: Added "dropdown-menu" class*@
How does one iterate through a dynamic collection to achieve such (coding certainly isn’t my forte)?
var items = Enumerable.Cast<dynamic>((System.Collections.IEnumerable)Model);
I’ve tried a foreach loop to collect/add the items to a static list [unsuccessfully, but that could've been my syntax] / or can I cast the above to such?? Any help or pointers on how to go about the above [or an already tried and true method] will be greatly appreciated, thanks in advance - Dyr