1
I have a problem running a request to enter a new user, I do not know what I need to do now to finalize my request, By clicking the sign up button nothing happens below are my HTML code and the controller (Controller Name: Usuariocontroller)
<form data-toggle="validator" role="form">
@Html.AntiForgeryToken()
<div class="form-group">
@Html.LabelFor(model => model.Nome, htmlAttributes: new { @class = "control-label" }) <br>
@Html.EditorFor(model => model.Nome, new { htmlAttributes = new { @class = "form-control", id = "Nome", placeholder = "Nome", required = "required" } })
@Html.ValidationMessageFor(model => model.Nome, "", new { @class = "text-danger" })
</div>
<!-- Confirmação de password -->
<div class="form-group">
@Html.LabelFor(model => model.Email, htmlAttributes: new { @class = "control-label" }) <br>
@Html.EditorFor(model => model.Email, new { htmlAttributes = new { @class = "form-control", id = "Email", type = "Email", placeholder = "Email", required = "required" } })
@Html.ValidationMessageFor(model => model.Email, "", new { @class = "help-block with-errors" })
</div>
<div class="form-group">
@Html.LabelFor(model => model.Senha, htmlAttributes: new { @class = "control-label" }) <br>
<div class="form-inline row">
<div class="form-group col-sm-6">
@Html.EditorFor(model => model.Senha, new { htmlAttributes = new { @class = "form-control", id = "inputPassword", placeholder = "Password", required = "required", minlenght = "6", type = "password" } })
@Html.ValidationMessageFor(model => model.Senha, "", new { @class = "help-block with-errors" })
</div>
<div class="form-group col-sm-6">
<input type="password" class="form-control" id="inputPasswordConfirm" data-match="#inputPassword" data-match-error="Opa, as senhas não batem" placeholder="Confirm" required>
<div class="help-block with-errors"></div>
</div>
</div>
</div>
<div class="form-group">
@using (Html.BeginForm("Adicionar", "Usuario", FormMethod.Get))
{
<button type="submit" value="Create" class="btn btn-success">Cadastrar</button>
}
<button type="button" class="btn btn-success" id="btn-login">Login</button>
</div>
</form>
<> // GET: User [Httpget] public Actionresult Index() { Return View("Index", Repo.List()); }
[HttpPost]
public ActionResult Adicionar(Usuario user)
{
Repo.Adicionar(user);
return View("Index");
}
[HttpPost]
public ActionResult Atualizar(Usuario user)
{
Repo.Atualizar(user);
return View("~\\Views\\Principal\\Principal.cshtml");//?
}
// DELETE : Usuario
[HttpDelete]
public ActionResult Delete(int id)
{
Repo.Deletar(id);
return View("Index", Repo.Listar());
}
Your question is not very clear, try editing. When editing I suggest you describe more details of the problem/error that is occurring. Analyzing the code I notice some strange things, but not to infer an answer without knowing exactly the problem.
– Renan
You didn’t report the problem you’re having... report the problem.. And by looking at yours
Controller
you defined two methods with the same nameAddUsuario
, without specifying which type requests will be receivedPOST
try to put theDataAnotation``HttpPost
in the method that receives theViewModel
as a parameter...– JcSaint