Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing Required Attribute from Class but MVC3 still won't post the form without a value in the text box

I have a class. At one point, I had set the properties of the class to [Required] using System.ComponentModel....

Okay, then I realized this was not needed. I have removed the required property but when I try to submit the form to an ActionResult the form does NOT post and still is trying to enforce the TextBoxFor(theModelProperty) to be populated.

I have deleted the "obj" folder, the "bin" folder, and also "Cleaned" the solutions. Still NO resolution.

I don't want to do a stupid workaround, I would like to do things correctly. Any idea why this occurs?

like image 816
Robert Green MBA Avatar asked Jul 25 '11 10:07

Robert Green MBA


1 Answers

You have two options:

  1. Set property as nullable,
  2. Turn off required attribute for value types (see this answer)
like image 125
frennky Avatar answered Oct 16 '22 08:10

frennky