Click here to Skip to main content
15,886,584 members
Articles / Web Development / ASP.NET

A sample on ASP.NET MVC Model Validation using DataAnnotations and ModelValidators

Rate me:
Please Sign up or sign in to vote.
4.29/5 (6 votes)
3 Jul 2011CPOL5 min read 92.1K   3.9K   28  
This article gives information to the reader on how flexible ASP.NET MVC validation framework is for complex validations on the form, also explains little bit on how ModelMetadata is created internally using provider model.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

using DataAnnotationSample.Models;

namespace DataAnnotationSample.Controllers
{
    public class EmployeeController : Controller
    {
        //
        // GET: /Employee/

        public ActionResult Index()
        {
            return View();
        }
        [HttpPost]
        public ActionResult Index(EmployeeModel objEmployeeModel)
        {
            return View();
        }

    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect
India India
I have around 9 years of experience in Microsoft technologies, .Net 2.0,3.5, Asp.net MVC developed small to medium scale products using Silverlight 2.0, Asp.net Ajax technologie and Javascript frameworks.

Comments and Discussions