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();
}
Written by Ion D. Filho
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#.net
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#