asp.net mvc IDataErrorInfo validation when using ViewModel


asp.net 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.


Setting the UpdateCheck.Never mode by default in Visual Studio 2010 DBML designer (MS SQL/ASP.NET MVC)

1:

Why would Application_Init fire twice when starting debugging in VS2008/Casini?
IDataErrorInfo doesn't job with child properties. ASP.Net MVC - Send Javascript Associative array to a controllerYou will need to implement this interface by the view model you are binding to (CategoryViewModel). Custom View Engine vs Custom Action ResultIt is also considered as bad practice. Asp.net MVC 2: Understanding CRUD, specfically actions Create ( there are 2)?As an alternative you might look at DataAnnotations or FluentValidation for more advanced validation scenarios.. jQuery posts data to wrong relative URL
Could not load file or assembly 'Interop.QBFC8Lib' or one of its dependencies

67 out of 100 based on 42 user ratings 297 reviews