Why is the type=Submit button not submitting?

Asked

Viewed 1,206 times

0

I am creating a form within the modal, when I try to submit it, not submit it.

My view:

@model GerenciadorDeAtividades.Dominio.AtividadeDominio

@{
    Layout = null;
    ViewBag.Title = "Alterar Status da Atividade";
}

<div class="modal-dialog">
    <div class="modal-content">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
            <h4 class="modal-title" style="text-align: center"><strong>Alterar Status da Atividade</strong></h4>
        </div>
        <div class="modal-body">
            @using (Html.BeginForm("AlterarStatus", "Home", FormMethod.Post, new { enctype = "multipart/form-data" }))
            {
                @Html.AntiForgeryToken()
                @Html.ValidationSummary(true)

                @Html.HiddenFor(model => model.CodAtividade)

                <div class="form-group">
                    @Html.LabelFor(model => model.Status)
                    @Html.DropDownListFor(model => model.Status, (List<SelectListItem>)ViewBag.Status, "Selecione um Status", new { @class = "form-control", style = "width: 50%" })
                    @Html.ValidationMessageFor(model => model.Status)
                </div>

            }
        </div>
        <div class="modal-footer">
            <button type="submit" class="btn btn-primary" id="InfroTextSubmit">Salvar</button>
            <button type="button" class="btn btn-default" data-dismiss="modal">Fechar</button>
        </div>
    </div>
    <!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->

@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}

My Controller:

public ActionResult AlterarStatus(string id)
        {
            var itensSelecionaveis = new List<SelectListItem>();

            itensSelecionaveis.Add(new SelectListItem { Text = "Testes ABAP" });
            itensSelecionaveis.Add(new SelectListItem { Text = "Testes Funcional" });
            itensSelecionaveis.Add(new SelectListItem { Text = "Aguardando" });
            itensSelecionaveis.Add(new SelectListItem { Text = "Validado" });
            itensSelecionaveis.Add(new SelectListItem { Text = "Retorno Ajuste" });
            itensSelecionaveis.Add(new SelectListItem { Text = "Concluido" });

            ViewBag.Status = itensSelecionaveis;

            repoAtividade = new AtividadeRepositorio();
            var atividade = repoAtividade.ListarPorId(id);

            if (atividade == null)
                return HttpNotFound();

            return View(atividade);
        }

        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult AlterarStatus(AtividadeDominio atividade)
        {
            appAtividade.Salvar(atividade);
            return RedirectToAction("Index");

        }

1 answer

4


Your button of submit is out of the form, places inside.

<div class="modal-body">
    @using (Html.BeginForm("AlterarStatus", "Home", FormMethod.Post, new { enctype = "multipart/form-data" }))
    {
        @Html.AntiForgeryToken()
        @Html.ValidationSummary(true)

        @Html.HiddenFor(model => model.CodAtividade)

        <div class="form-group">
            @Html.LabelFor(model => model.Status)
            @Html.DropDownListFor(model => model.Status, (List<SelectListItem>)ViewBag.Status, "Selecione um Status", new { @class = "form-control", style = "width: 50%" })
            @Html.ValidationMessageFor(model => model.Status)
        </div>   
        <div class="modal-footer">
            <button type="submit" class="btn btn-primary" id="InfroTextSubmit">Salvar</button>
            <button type="button" class="btn btn-default" data-dismiss="modal">Fechar</button>
        </div>

    }     
</div>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.