0
I am creating an application in Asp.NET MVC (I am using the Scafffolded feature), however, all the whole fields are being required to be filled in, as I remove this parameter?
Note: I have tried to uncheck the "Allow null value" option in the database, but without success.
I’m guessing this validation is taking place at .cshtml
, but I couldn’t locate.
Model.
public class prospectModel
{
public int id { get; set; }
public string contato { get; set; }
public string nomeRazaoSocial { get; set; }
public int documento { get; set; }
public int telefone { get; set; }
public int celular { get; set; }
public string email { get; set; }
public string anotacoes { get; set; }
}
cshtml
<div class="form-group"> @Html.LabelFor(model => model.celular, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10"> @Html.EditorFor(model => model.celular, new { htmlAttributes = new { @class = "form-control" } })@Html.ValidationMessageFor(model => model.celular, "", new { @ class = "text-danger" })
</div>
</div>
How is your model? The properties are as
Required
?– rLinhares
It depends, the html it fills as required only some data types ... as for example type: number ... your . cshtml is as ?
– John-Jones
It’s not like Required :(
– Cristian
Edit your answer, do not get code in the comments that the view looks bad.
– Marco Souza