1
I created Asp.net mvc core 2.2 project with individual account.
Follows code:
[BindProperty]
public InputModel Input { get; set; }
public class InputModel
{
[Required(ErrorMessage = "O campo \"Cartão\" é obrigatório")]
[Display(Name = "Cartão:")]
public string Card { get; set; }
public List<SelectListItem> Cards { get; set; }
}
if (ModelState.ContainsKey("Input.Card"))
ModelState["Input.Card"].Errors.Clear();
With this code above does not work, the following code works:
ModelState.Clear(); // Limpa todos
I’ve tried that way and it doesn’t work:
foreach (var modelValue in ModelState.Values)
{
modelValue.Errors.Clear();
}
Still the same mistake in ModelState
.
I’m unable to clear a specific property error, some solution ?