Steve Michelotti

A .NET Developer's Toolbox

  Home  |   Contact  |   Syndication    |   Login
  201 Posts | 0 Stories | 1110 Comments | 51 Trackbacks


View Steve Michelotti's profile on LinkedIn

profile for Steve Michelotti at Stack Overflow, Q&A for professional and enthusiast programmers

Google My Blog

What I'm Reading:

Shelfari: Book reviews on your book blog

Tag Cloud


Post Categories



June 2008 Entries

The latest release of the MVC framework provides the JsonResult for Controller actions. I was surprised that I did not find a weatlh of examples for usage so I figured it shouldn't be too hard to get a decent example going. It turns out, it was even easier than I anticipated. I wanted to create an example where I would invoke an AJAX call to dynamically populate a dropdown list. jQuery has recently received a huge surge of interest of the ASP.NET MVC community so I've been getting up to speed on ......

To set a normal text box in the MVC framework, the most typical code would look like this: 1: <%=Html.TextBox("FirstNa... ViewData.Model.Contact.Firs... The key here is that you should set the name of the textbox to be the exact same name of the property name. If you do this, then it enables you to use extension methods such as the UpdateFrom() method to automatically populate your object from Request.Form parameters when you post to your controller action. This is all well and good but ......

UPDATE: This post is now out of date as of the CTP5 release of the MVC framework. For the lastest version, see this post here. One of the areas of MVC that is still an open area in development is how best to handle UI validations. There are numerous approaches currently being examined. MVCContrib Validator Toolkit for MVC The Enterprise Library's VAB is great because it allows you to specify all your validation logic in your business layer where it belongs rather than in your UI. Additionally, it ......

The Enterprise Library VAB provides the PropertyProxyValidator for ASP.NET applications so that you can attach it to a single control and it will display any validation messages for that business object property. This automatic UI validation is great because it avoids duplicating your business layer validation logic in your UI. Additionally, you can just use ONE validator control whereas using traditional ASP.NET validation controls you might need to attach 3-4 validation controls to a single UI ......

In a previous post I discussed validating strings with the VAB in the context of ASP.NET applications. In summary, you must have a NotNullValidator and also a StringLengthValidator that prevents a string length of zero on the lower bound and prevents a string length above your upper bound (e.g., 50 characters). That attribute might look like this: 1: [StringLengthValidator(1, 50, MessageTemplate="First Name must be 1-50 characters.")] But the problem is that the StringLengthValidator is really doing ......

You've created a class like this and all your unit tests pass just fine when you check for null strings or strings greater than 50 characters: 1: public class Person 2: { 3: [NotNullValidator(MessageTe... Name is required.")] 4: [StringLengthValidator(50, MessageTemplate="First Name must be 1-50 characters.")] 5: public string FirstName { get; set; } 6: } But then when you run it in an ASP.NET application with the PropertyProxyValidator validation control provided by VAB, your business ......