5

ASP.NET WebForms seemed really great until that moment of realization the abstraction you'd welcomed was producing HTML that was worlds away from what you needed. Wrestling with that framework to generate HTML that matched a designers or used external libraries became a big nightmare for me and one I'd rather not have again.

When approaching a simple Bootstrap form in ASP.NET MVC I copied over the basic HTML and then started the process of adding @Html.BeginForm(), @Html.EditorFor() until it hit me that I was going down the same path. Sure, you add an attribute here, define an alternate helper there, but how long until you are fighting the framework to get back to what you could have just pasted in from any Bootstrap example on the web?

Is anyone else feeling that, or is it possible that the Helpers introduce enough "sugar" to make using them worth the effort?

closed as primarily opinion-based by gnat, GlenH7, Dynamic, user7007, Bart van Ingen Schenau Dec 21 '13 at 10:50

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.

2

You are certainly right to be skeptical of them, but I think they are different enough from Web Forms to alleviate your concerns. The biggest problem with Web Forms is that it pretended the Web didn't exist. It tried to make everything feel like a Windows application, which caused a lot of weird HTML output on pages to keep track of sessions, ViewState, etc.

ASP.NET MVC doesn't have that same fundamental abstraction. It's a web framework for the web. Although I still hand-code a lot of HTML, one of the nice things about the HTML helpers is that you can define what the actual HTML output is--so, for instance, you can have all decimals display as currency and keep that code in one place. I like, most of all, being able to pick and choose when I want the raw code and when I want to make my life a little easier and just use the Helper. I've personally replaced all of the HTML helpers for DisplayFor() and EditorFor() to use formatting that I prefer in my projects. It cuts down on copy-and-paste for me a lot.

  • Agreed, and the dynamic generation of validation markup from lambdas is priceless. – Mr Cochese Dec 17 '13 at 9:25

Not the answer you're looking for? Browse other questions tagged or ask your own question.