views:

429

answers:

2

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?

+2  A: 

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.

Dennis Palmer
A: 

It is always a good idea to be lazy and save yourself some repetitive work.

It shouldn't be slower than having a view with all elements directly on it and no partial render calls.

User