10-4 Episode 37: Leveraging Model Metadata and Validation with ASP.NET MVC2

Play 10-4 Episode 37: Leveraging Model Metadata and Validation with ASP.NET MVC2

The Discussion

  • User profile image

    I like it, but is there a way to create a user friendly message for the REGEXP validation?

  • User profile image

    Ditto on the RegEx validation question.  Great presentation and awesome technology!

  • User profile image

    Great question, and fortunately the answer is yes Smiley I tried to keep the video short, so I couldn't go into every scenario, but all of the validation messages can be customized, as well as localized by using resource files. In the video I just simply used the default messages for example.

  • User profile image

    In your demo you had a reference to jquery.validation? How easy to use it on the client-side?

  • User profile image

    The client-side validation that MVC uses is fully extensible, and it's pretty simple to wire-up a custom implementation. Out of the box, the validation uses MS AJAX, and if you want to use jQuery validation, there is an implementation of that in the MVC futures project (here). If you have any troubles getting it to work, feel free to e-mail me (joncart at microsoft dot com).

  • User profile image
    Zack Peterson

    This handles formatting validation well.  Could I add a custom validation?  For example, can I verify that a new airport code is unique in the database?  Does that belong somewhere else?

  • User profile image


    I’ve just started a new project in ASP.net 4.0 with MVC 2.

    What I need to be able to do is have a custom hook at the start and end of each action of the controller.


    public void Index() {
        *** call to the start custom hook to externalfile.cs (is empty so does nothing)

        ViewData["welcomeMessage"] = "Hello World";

        *** call to the end custom hook to externalfile.cs (changes "Hello World!" to "Hi World")

        return View();

    The View then see welcomeMessage as “Hi World” after being changed in the custom hook.

    The custom hook would need to be in an external file and not change the “core” compiled code. This causes a problem as with my limited knowledge ASP.net MVC has to be compiled.

    Does anyone have any advice on how this can be achieved?

    ThanksGeneric Comment Imagecomputerslanditcomputer computerslookup laptop video card sevenwebhosting.org

Add Your 2 Cents