Framework Madness!

And other adventures C# and …

Posts Tagged ‘mvc

Data Annotations : MVC 2 Preview 1

with 4 comments

That title is a mouth full.

Moving on – if you don’t know by now the MVC team posted their first draft of v2 last night along with a few blogs posts and a Scott Hanselman Channel 9 video. And while the first hint at Areas looks incomplete, the work on Data Annotations looks very promising.

I have been doing a major eCommerce project at work leveraging 3.5 Dynamic Data along with Entity Framework for the admin. Using Dynamic Data has really cut my development time and I couldn’t fathom leveraging MVC without similar support. Well, MCV v2 Data Annotation support thus far appears similar but stripped down like the MCV types like it. Support comes from several improvements:

  • Display and Editor Templates: these are user controls that can be used to create display and editing output for properties specified by Data Annotations applied to the model. These are similar to field templates. However, they can be used for more than just values types, you can make controls for complex types as well.
  • Strong Typed UI Helpers: these extensions of the Html object inside a view not only allow for using lambda expressions for specifying output but also act as the gateway to leveraging Display and Editor templates. And of course using lambda expressions adds compile time support.
  • Data Annotation Validation: model validation now supports data type validations in the controller and returning the same view returns the correct validation error messages.

This really gets my interest in MVC going. The lack of controls is frustrating but I could live with out them. I cannot however live with out Data Annotation UI and validation support so this makes MVC much more approachable in the near term. The rest of the details are in the revised road map.

It looks like future previews will improve on all current features and add a few additional things to boot. How much get’s added to MVC v2 ultimately will be limited by the teams stated goal of being on the  VS 2010 DVD which will probably ship next spring.

More information:

Written by Lynn Eriksen

July 31, 2009 at 6:39 am

Posted in Uncategorized

Tagged with , , MVC – Why?

leave a comment »

I have been using Web Forms since the 1.0 Beta 2 release in late 2001.  At the time of it’s release as a whole eclipsed ASP classic in many ways. But like any technology its was designed to solve the technology of it’s time. However, in recent years many of these solutions that Web Forms solves are no longer problems, and quite often today much of what comprises Web Forms and it’s elaborate control architecture seems … unnecessary. Since is really just making the .Net framework available for web page creation many of the functional decisions can be traced to browsers of the day. So what was that environment?

  • IE 5/5.5, IE 5 for Mac, and Netscape for 4.x all had a very different support for html layout and css styling.’s controls could adapt html css style output depending on what kind of browser was making the request. This would often result much different html and css being sent to the various browsers, depending on the control in question.
  • The XmlHttpRequest object, the X in AJAX, existed primarily in IE for Windows at the time. therefore requires full page post backs, but with the existence of control model that emulated state – that allowed for only one form per page and elaborate sever side control pipeline. If you have ever tried to write an elaborate server control you know.
  • The JavaScript environments varied wildly between the browsers, so aimed squarely at a creating a pseudo event-driven environment on the server that would allow for a more consistent programming environment. And sure – some control such as validators supported JavaScript in IE, but would transparently run the same code on the server if the browser requesting the page didn’t measure up.

So it was a big win for lots of us developers, upcoming and established alike. That was 2000-2001.

Flash forward six or seven years later and all of the scenarios above can be easily handled by all major browsers on Windows, Mac and Linux either by the browser alone or with the assistance of JavaScript libraries. The success of the .net framework and have brought in a bucket load of developers that find .net Framework to be powerful but engineered. And those of us that have persisted have learned that simpler is almost always better, test if you want to make a living, and you should only have to write your code once. Web Forms wasn’t really engineered for these concerns, so the case for adopting Model-View-Controller as an alternative web platform within was born.

Written by Lynn Eriksen

June 22, 2009 at 10:22 pm

Posted in Uncategorized

Tagged with ,