When implementing a helper extension for a similar navigation widget to the one described in this article I notice that my HTML is now tied up in C# code, so if I want to re-skin the site with a new menu control that needs slightly different markup (e.g <ul class="foo">...</ul> or distinct class names for nested <li> tags) I now have to edit both the helper extension and the view.
Using a helper extension is quicker and easier, but does this not violate separation of concerns? What are your experiences of maintaining such code? I’m fairly new to Microsoft MVC so forgive me if I’m missing some point here.
A well-designed HTML Helper should be versatile and have very loose opinions about how it builds its HTML. You can add overridable options to the extension method so that the rendering is as configurable as necessary. If you have new requirements and your existing helper isn’t flexible enough, extend it to accommodate the new requirements.