2
When we create a project in Asp.Net it by default inserts some validators to be used with Razor, @Html.ValidationMessageFor(model => model.property)
.
I saw in different projects that these messages are generated through the return of the controller
, that is, when the form is sent, it checks the ModelState
and according to the answer, brings the mandatory fields and so "active" the message for what is missing, however, I have also seen in some projects that he does not need to enter the controller
to perform the check, what I need to know is what defines this situation.
What does the validator do before entering the controller
know which fields need to be filled in?
EDITION:
I think I’d better insert the Crypts that carry out the validations and also the others that I use to know if any is disturbing the other.
Follow the code below:
<script src="~/Scripts/jQuery-2.1.4.min.js"></script>
<script src="~/Scripts/jquery.validate.min.js" type="text/javascript"></script>
<script src="~/Scripts/jquery.validate.unobtrusive.min.js" type="text/javascript"></script>
<script src="~/Scripts/bootstrap.min.js" type="text/javascript"></script>
<link href="~/Content/bootstrap.min.css" rel="stylesheet" type="text/css" />
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
<link href="~/Content/template/css/AdminLTE.min.css" rel="stylesheet" type="text/css" />
@*USAR NESTA ORDEM*@
<link href="~/Content/template/css/skins/_all-skins.min.css" rel="stylesheet" type="text/css" />
<link href="~/Content/jquery-confirm.css" rel="stylesheet" type="text/css" />
<link href="~/Content/meucs.css" rel="stylesheet" type="text/css" />
<script src="~/Scripts/angular.min.js"></script>
<script>angular.module("Angular", []);</script>
<script src="~/Scripts/tecbox/MainController.js"></script>
<script src="~/Scripts/modernizr-2.8.3.js" type="text/javascript"></script>
That means you don’t have to insert the properties into the html elements at hand, right? Because I have another project here that works, I just can’t find the problem. They’re practically the same.
– Luiz Negrini
Right. You just memorize the attributes. The rest framework does it for you.
– Leonel Sanches da Silva
Something is wrong, I’ve innervated a breakpoint in the controller and it’s still being called.
– Luiz Negrini
Then went to the Controller, or you set up your project wrong.
– Leonel Sanches da Silva