mvc IDataErrorInfo validation when using ViewModel mvc IDataErrorInfo validation when using ViewModel

I have used IDataErrorInfo Validation for my Model. But when I use these model classes inside a view model, the validation does not happen.

sample viewmodel below

public class CategoryViewModel     {     // Category class with IDataErrorInfo     public Category category { set; get; }      // Subcategory class with IDataErrorInfo     public IList<SubCategory> subcategory { set; get; } } 

Now, if Category or Subcategory classes are directly used as models for view, the validation works fine. But, if CategoryViewModel is used, no validation occurs.

How to use TextBoxFor to update the many side of a relationship


looking for suggestions on how i can highlight areas on an image
IDataErrorInfo doesn't work with child properties.

Wanting to mix server side ASP.Net MVC expansion in javascript file, but how… RenderPartial?
You will need to implement this interface by the view model you are binding to (CategoryViewModel).

Problem with Primary Key in a Partial View shared by Create and Edit views
It is also considered as bad practice.

How to start a new ASP.NET MVC site?
As an alternative you might look at DataAnnotations or FluentValidation for more advanced validation scenarios..
How can I determine the current controller action in an mvc sitemap?

Check ASP.NET MVC values (roles) from client (jQuery)

57 out of 100 based on 52 user ratings 227 reviews