I want to output a menu structure that will look like this
<ul>
<li>
MenuItemName1
<ul>
<li>Child Item</li>
</ul>
</li>
<li>
MenuItemName2
</li>
</ul>
I have a menuitem class that contains the name, url and children menu items. I would like to create a partial view that renders each item as an unordered list like above and I would call it recursively to go through the entire tree.
Is this a bad idea?
Will it be very slow?
I’m doing this and it doesn’t seem particularly slow, but it’s not a high volume site. Would be a great place to wire in some caching.
Check out the answers to my question on the same topic. I think the HTMLHelper extension method might perform a bit better than nested partial views.