asp.net mvc - MVC and XVal with drop downs - The value 'Please Select' is invalid -
After the outlook I mentioned to it.
Im having a dropdown selection validation is a problem with the excaval, MVC binding, understanding the wrong thing which allows the operation to pass verification, but the modelstate binding stores the exception and the page Invalid - so I get the position where the operation is allowed to execute with invalid data, but the page is invalid so the user has to trust Failed to believe in Ritw.
This can make it clear
This is my drop, assume that the user did not do anything like this "Please select" is chosen.
Do you like cheese: & lt; Select Name = "Favorite. Chase" & gt; & Lt; Options & gt; Please select & lt; / Options & gt; & Lt; Option value = "1" & gt; Yes & lt; / Options & gt; & Lt; Option value = "0" & gt; No & lt; / Options & gt; & Lt; / Select & gt; & Lt;% = Html.ValidationMessage ("Favourites.Cheese")%> This is the action of the controller, even by posts, MVC considers the map to be incorrect for fav.cheese,
create public function (favorite fav) {Try {_favTask.Create (fav); } Hold (rule exceptions) {ex.AddModelStateErrors (ModelState, "Favorites"); } If the property has been attributed to (
policy class favorites { Required] public hair cheese {get; Set;}} No exceptions are thrown because fav.cheese has a value
create public int (favorite fav) {var errors = data annotation ValidationRunner . GetArters (FAV); If (Errors any) throw exceptions (errors) to new rules; // create fav} But when the focus controller returns to the modelstate ISIVIG comes out as a liar, so this message is reloaded from Value 'Please select' is invalid. How do I stop it and what is going on and how do I do the xVal induced method of "Select a value"?
Boolean is a value type, so it will always be a value [required] so there is no real effect If you are a qualified & lt; Bool & gt; Instead? If MVC is opted for the first option, then MVC should allow an empty value to be assigned, and the required attribute can again say that the user actually chooses a value.
Comments
Post a Comment