Override string Menu()?

Sep 1, 2010 at 4:00 PM
Edited Sep 1, 2010 at 6:56 PM

I would like to modify the html output by your MenuHelper Menu() method.  I'm a .NET novice.  Is there a way to override the final function to allow control of the markup generated?  Or do I have to add a C# project to my solution, replace the source, and ref that way instead?

If I have to override, perhaps consider allowing a template/viewmodel the end developer can customize for this method's html output.  Would like to add extra css classes (first, last, etc) and different markup structure

Sep 9, 2010 at 6:52 PM

I'm planning on making the helpers more "fluent", where you can interfere in every step of the rendering process. Still thinking about a good API there though. Suggestions welcome :-)

For now, your suggestion with a new c#projetc is the better choice.

Oct 6, 2010 at 1:59 AM
Edited Oct 6, 2010 at 2:01 AM

What about having it act like RenderAction, where you can specify which partial view to render?  The partial view's model would be the site map data to render.  This would allow us to customize the html output of the menu.  Maartenba, Have you thought of doing this?  

Oct 6, 2010 at 11:14 AM

Good one! It would allow you to specify partial views for every possible situation (selected, not selected) and only override those that matter to you.

Oct 7, 2010 at 9:11 AM

Check here for discussion.