As I referenced last night, I've been advocating "custom controls everywhere" for a long, long time. I don't approve of using the <asp:Textbox> control or <asp:DataGrid> control, or pretty much any others. Instead, these controls should be inherited, and the derived controls should be used.
There are many reasons for doing this, and I've given a few user group talks on this and I've offered tidbits in my blog over the years. But I've been thinking about how ASP.NET MVC will hinder my ability to use custom controls everywhere, and what I should do about that.
The problem is that ASP.NET MVC offers HTML UI Helpers instead of actual controls. These helpers are functions that return HTML snippets inline. It feels just like what I did back in ASP days when trying to encapsulate common HTML blocks (VBScript, yea!!). And honestly, it seems like a huge step backward. Using ASP.NET MVC, I immediately miss the form and validator controls. On a large project, I know I'd miss my derived datagrid that has tons and tons of goodness baked in, especially when mixed with custom datagrid columns.
This post serves as part 0 of a 4-part series on the topic. During this series, I am sure that many MVC purists will disagree with what I have to say, because what I will present isn't "pure" MVC. That's okay, and comments are welcomed! For many of us though, we don't care about using MVC in its virgin state; rather, we want to build maintainable, quick-to-develop, user-friendly applications, regardless of the pattern applied. The MVC pattern has many offerings that provide maintainability, but there seems to be some loss in developer efficiency and user experience.
- Part 0 (this post) - Announcement of the series
- Part 1 - Why to use Custom Controls Everywhere, and how ASP.NET MVC takes away the capability
- Part 2 - How to implement Custom Controls Everywhere, using ASP.NET MVC
- Custom Controls Everywhere is Cheap!
- Intermission and Disclaimer about Parts 3 and 4
- Part 3 - How the ASP.NET MVC framework could change to offer a lot more extensibility and customization
- Part 4 - Adding client-side validation to the concept
Please tune in and watch where this goes. I would love to hear candid comments and constructive criticism. Heck, I even invite you to blast me for not knowing what the heck I'm talking about. Hit me with whatever you got. But in the end, I promise that I will have presented a means for encapsulating common HTML in a form similar to what we're used to in traditional ASP.NET. And this approach will offer a means for customizing those controls for an application, ensuring a consistent user interface, improved developer efficiency, and better maintainability.