How to pass a view ID without a template

Asked

Viewed 58 times

1

I’m trying to send a template-less view ID to a controller, but I’m not getting it. the code I have is as follows:

View

@model string
@{
    ViewBag.Title = "Edit";
    string classHtml = "";
}

@using (Html.BeginForm(null, null, FormMethod.Post, new { id = "signupformInformacoesDiligencias", enctype = "multipart/form-data" }))
                {
                    @Html.AntiForgeryToken()
                    @Html.Hidden("idProcesso", (long)ViewBag.IdProcesso)
                    @Html.Hidden("idInformacao", (long)ViewBag.IdInformacao)

<div class="col-md-6">
                                                <span style="float:right">
                                                    <button class="btn btn btn-primary" onclick="AjaxBegin()" type="submit" data-toggle="tooltip" title="Guardar">
                                                        <i class="fa fa-save"></i>
                                                    </button> &nbsp;&nbsp;&nbsp;
                                                    <a class="btn btn-info" href="@Url.Action("index", new { id = ViewBag.IdProcesso })" style="float:right;" data-toggle="tooltip" title="Voltar">
                                                        <i class="fa fa-mail-reply"></i>
                                                    </a>
                                                </span>
                                            </div>
}

Controller

[HttpPost, ValidateInput(false)]
        public ActionResult _ComunicaDiligencia(long idProcesso, string mensagemHtml, string emailsEnvio, string assunto, int? idTipoAveriguacao)
        {
            long saiId = 0;
            string saiMensagem = "";
            string utilizador = HttpContext.User.Identity.Name;
            Processos_Logic processoLogic = new Processos_Logic();
            ProcessosInformacoes_Logic processoInformacoesLogic = new ProcessosInformacoes_Logic();

            Processos_Model processoModel = new Processos_Model();
            ProcessosInformacoes_Model processoInformacoesModel = new ProcessosInformacoes_Model();

            processoInformacoesModel = processoInformacoesLogic.DevolveRegistoPeloId(idProcesso);
            processoInformacoesModel.IdTipoAveriguacao = idTipoAveriguacao ?? 0; //caso o tipo de averiguação seja nulo, leva o valor zero para a base de dados

            //Envio Relatorio Companhia
            new ProtocolosIntegracaoSaida_Logic().EnviaRelatorio(idProcesso, utilizador, mensagemHtml, emailsEnvio, assunto);

            return RedirectToAction("Index", "ProcessosAveriguacaoInformacoes", new { id = idProcesso });
        }

What I might be doing wrong?

  • Try putting an extra attribute in your Actionresult "Formcollection form", debug and see if the value is being received within that variable.

  • or add the [FromBody] before the statement of the arguments in its action

No answers

Browser other questions tagged

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