Blog

  • I'm a fan of the Data Annotation Validation attributes to validate user input on both the client and server side for ASP.NET MVC applications. I'm also a fan of Inversion of Control and Dependency Injection to create loosely coupled and flexible applications. There are certain situations where one would wish to inject services into a validation attribute to use during validation; a (somewhat contrived and security cautious) example of this might be providing the user with a <select> element and ask them to choose an option from it and then validate that the option that they have chosen is one that actually exists for the type of items represented in the dropdown. Sure, the RemoteAttribute would allow you to call a server side method via AJAX to perform validation but it does not provide any server side validation, making it more of a convenience solution than a complete and robust one. What would be good is if we could

    1. provide services to a validation attribute that could be used in the process of validation
    2. Not have to explicitly resolve services from the container à la the Service Locator (Anti-)Pattern

    Read more…

  • Having a good url routing scheme is extremely important when developing an application. Urls should be canonical to aid in search engine optimization and discoverable in order to aid users in learning where to find application functionality for particular tasks. But there are points in an applications lifecycle where one wishes to change the url routing scheme in order to employ a better one. In such instances, URL redirection can be used to preserve search engine rankings, user bookmarks to specific pages or to allow more than one URL to serve up the same content, as is the case when employing URL shortening.

    Read more…

  • Part one of jQuery Event internals looked at the DOM Event specifications, the history of the Document Object Model (DOM) event models and reasoning behind why jQuery has an event system. In the second part of this series, we'll be looking at the jQuery.event object and jQuery.Event constructor function, both of which play a pivotal role in managing events. Previously, we looked at the bind() method (and the related specific event handler binding methods such as click(), keyup(), etc) and saw that bind() eventually calls jQuery.event.add, so let's start by looking at that.

    Read more…

  • I’ve been using jQuery for a number of years now and think it’s an awesome JavaScript library for providing a rich client experience to web applications with little effort.  Whilst I advocate the use of jQuery to quickly and effectively build your client side solutions, I also think that it’s important to understand what’s going on under the hood, particularly as it can help to quickly pinpoint a bug in your own code (and on the rarest of occasions, a bug in the library code).

    Read more…

  • UPDATE: I've added a simple example project up on bitbucket to demonstrate the ColorPicker attribute

    ASP.NET MVC 3 introduces a new interface, IMetadataAware, for providing additional values to the model metadata at creation time:

    /* ****************************************************************************
     *
     * Copyright (c) Microsoft Corporation. All rights reserved.
     *
     * This software is subject to the Microsoft Public License (Ms-PL). 
     * A copy of the license can be found in the license.htm file included 
     * in this distribution.
     *
     * You must not remove this notice, or any other, from this software.
     *
     * ***************************************************************************/
    
    namespace System.Web.Mvc {
        // This interface is implemented by attributes which wish to contribute to the
        // ModelMetadata creation process without needing to write a custom metadata
        // provider. It is consumed by AssociatedMetadataProvider, so this behavior is
        // automatically inherited by all classes which derive from it (notably, the
        // DataAnnotationsModelMetadataProvider).
        public interface IMetadataAware {
            void OnMetadataCreated(ModelMetadata metadata);
        }
    }

    Read more…

  • I'm probably a little late to the party on this one, but I have just started listening to This Developer's Life, a podcast presented by Rob Conery and Scott Hanselman. Each episode focuses on a particular topic in the realm of development and technology in general and involves interviews and stories from some of the most well known faces in the industry. There are some genuine legends, both past and more recent, shooting the breeze for our listening pleasure. These stories are interspersed with some great choices of music and short stories from the two presenters. I think there's something in there for everyone interested in technology and, like me, you'll probably find yourself relating to more than one of the topics brought up.

    Read more…