0ybdig
Last Updated: February 25, 2016
·
2.446K
· iondrimba
178548

Removing Custom Validation from Class in asp.net mvc 3/4

If you need to remove a custom validation attribute from a class before saving it but you don´t have access to the class file, you can remove it at runtime.

public ActionResult Save (Type object)
{
   ModelState.Remove("objectPropertyName");

   if(ModelState.isValid)
   {           
     //continue saving procedure          
   }
   return View();
}
Say Thanks
Respond