Sponsored By Aspose - File Format APIs for .NET

Aspose are the market leader of .NET APIs for file business formats – natively work with DOCX, XLSX, PPT, PDF, MSG, MPP, images formats and many more!

Random responses to MVC comments

Some pretty good comments in my most recent post on (re-)learning HTML in order to work with MVC. A few worth expanding upon.

Will Shaver says:

Actually… I’d counter that Javascript is the hardest tool in the box to use correctly. Harder than c#, sql, asp.net, webforms, html etc. It has several KEY differences to all other object oriented languages in the standard toolbox. Prototypal inheritance, functions are objects, objects are containers.

Even worse is the massive amount of BAD information out there for javascript. For example the || is the "default" operator and has different meanings in Javascript than in c#!

For more, read your crockford….

The Hillbilly says:

Yeah, I did kind of gloss over the intricacies of Javascript. If you use it to its full capacity, it can be pretty tough to understand. I have only vague notions of its inheritance mechanism. But the Javascript libraries available today make it easy to use without having to delve crazy deep into the more advanced concepts. I’m dancing around the line between encouraging you to look into its inner workings and encouraging you to use a library so you don’t have to. Not sure where the trade-off is because I don’t think I’ve found it yet. But Javascript still isn’t too bad.

Helen says:

For me the lack of server controls is a big reason that MVC doesn’t look too appealing to me because they’re a big help in reusing repeated elements on different pages. WebForms is definitely a framework that’s showing it’s age but I kind of feel like Microsoft threw the baby out with the bath water when they designed MVC.

The Hillbilly says:

To be clear, and you probably already know this, WebForms isn’t going away by any stretch. And MVC is not the next evolution of WebForms. It’s a framework for building apps on the web, just like WebForms is.

But the nature of MVC as it applies to the web is such that server controls don’t make a whole lot of sense. Server controls are all about managing state. The web is stateless. MVC doesn’t throw away server controls. It just doesn’t accommodate them because of environmental restrictions.

Also, user controls are still supported in MVC, though again, you can’t really use server controls in them. Only standard HTML elements. Which means you need to manage the state yourself. And in my experience, that’s a good thing because user controls are traditionally where I’ve had to become, shall we say, "familiar" with the ASP.NET life cycle.

Łukasz Podolak says:

Could you explain :

"Or at the very least, that it’s never been easier to add rounded corners to a DIV." ?

The Hillbilly says:

I was being flippant actually but just the same, I haven’t had too much trouble. I’m using jQuery and this plug-in. I did have a problem with it working in IE because it uses excanvas which apparently IE doesn’t support natively. But this library helped solve that issue. There are other plug-ins for jQuery and I’m sure you’ve tried some non-jQuery ones but I like this one because it doesn’t add a bunch of nested DIVs to your elements to achieve roundedness.

Charlie Barker says:

The problem they have failed to come up with a solution for (as far as i know) is the 3rd party controls issue. 3rd party control developers need a way to plug their controls into the MVC framework. Without this small in-house dev teams that rely heavily on these controls will have to stick with webforms.

The Hillbilly says:

That question came up as well. As yet, I haven’t found any companies offering third-party controls though I admit I haven’t looked too hard. It’ll be interesting to see what comes out because they’ll be "limited" to what can be done in HTML. I don’t foresee this being a big deal though because everything that’s possible in WebForms should be possible in regular HTML, mostly because WebForms controls *are* HTML when you get right down to it. Besides which many of the vendors already offer AJAX versions of their controls. It will be a matter of getting their hands dirty and scaling back to the basics.

Keep the comments coming. This was one of the easier blog posts to write.

Kyle the Verbal

This entry was posted in ASP.NET MVC. Bookmark the permalink. Follow any comments here with the RSS feed for this post.
  • http://www.dualbotic.com/dasBlog Charlie Barker

    @Ken Egozi

    I agree wholeheartedly about what there is to gain in terms of cleaner markup but the more advanced grid controls like Intersoft’s webgrid offer features like column freezing and filtering (similar to excel’s auto filter). Our users would not take kindly to losing these features. We don’t have the time to go looking for javascript alternatives if they even exist. Maybe if we were starting from scratch we could contemplate using MVC.
    I also agree that the javascript library’s are catching up but they are not there yet on the Grids.

  • RobT

    Well, a couple quasi-agree/quasi-disagree points.

    Javascript is not hard at all. It’s just unnecessarily obtuse, oblique, and opaque. Debugging it is a pain, and aside from the already stated fact that it shares many features with C-ish languages, yet deviates painfully in similar constructs with C# and Java (and even Python), which makes some things prone to bugs raised from confusion (or just not paying extensive attention). Additionally, it doesn’t work the same in all browsers, although for the most part, that’s the fault of DOM implementation. Like all scripting languages, there’s no way to tell something will go wrong until it actually does, at runtime, sometimes at the most inopportune moments, even with tests. I normally have a phrase for OOP – consuming OOP libraries is infinately easier than constructing one, and I guess the same applies to Javascript. That is to say, using pre-defined JS libraries is in fact really easy, but building your extensive code or plumbing with JS is just plain painful in comparison to many other languages. So it’s important to note that this is in fact a major pain point for web development, and can’t be *that* easily dismissed.

    Also, I’ll second that I hate server control state management. Viewstate/Controlstate bugs the crap out of me. We’re in full agreement there. However, I do think that the OO nature of server controls is fantastic for handling rendering and other more complex coordination issues. That’s something I feel needs to “grow up” a bit more with the MVC frameworks for the web. There is already some progress, but it certainly isn’t as far along as many of the MVP frameworks for client-based GUIs.

  • http://16randombytes.blogspot.com Bill Barry

    I would very much encourage every web developer to try to actually understand javascript. It is a very powerful language and so long as we can keep getting IE to try to get better, the language can only get better.
    One resource I have always liked is:

  • http://www.kenegozi.com/blog Ken Egozi

    the “3rd party controls” is so much _not_ an issue.
    given the purer HTML you get when you work with the non-WebForms stuff, you ‘lose’ the crappy over-bloated 3rd party WebForms controls, which are a tiny fraction of the 3rd party controls in the DHTML world.
    there are so many more widget toolkits for the web, that are client side based, and they all work very well with web guidelines (cleaner markup, no chatty ajax calls, cross-browser js and css), and the look the hell better

    So, non-issue at best.

  • Kyle Baley

    @Fregas: There are also a lot of decent alternatives out there already. I stumbled across Ajax Data Controls (http://dotnetslackers.com/projects/AjaxDataControls/) just this morning courtesy of http://elijahmanor.blogspot.com/. He also mentioned the jQuery Flexigrid which looks pretty cool: http://webplicity.net/flexigrid/

  • http://www.dotnettricks.com Fregas

    We’ve also discussed the controls issue and what we’re starting to find is that there are a lot of things you can do without “controls” per se by relying on the javascript libraries like prototype and scriptaculous. Dojo is one we’re looking at particularly as it has trees, grids, editors, and all sorts of things.

    This is actually and advantage because our UI guys, who are not asp.net gurus actually prefer to use these native javascript libraries, css and html, rather than having to fight the learning curve associated with skinning many 3rd party controls.