-1
I’m trying to pass a figure on Controller
for View
, here is how it is in the View:
<div class="alert alert-danger alert-dismissable" role="alert" id="alerta">
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
@Html.Raw(ViewBag.Mensagem)
@ViewBag.Mensagem
@Model.Message
</div>
And here’s how it’s in the controller:
if (cod != null && msgm != null)
{
ViewData["Mensagem"] = "Código: " + cod + ". Erro: " + msgm;
obj.model.Message = "Código: " + cod + ". Erro: " + msgm;
ViewBag.Mensagem = "Código: " + cod + ". Erro: " + msgm;
return View(obj.model);
}
But neither of the two receives the values, always stays blank, as if receiving nothing. I don’t know why it happens, I was using ajax to show Alert, I thought it could be this, but I always make it visible, and also the problem occurs.
I’ve tried going by ViewBag
, ViewData
and even for the same variable, none of them receives.
@Messaging is not the same as defined in your Viewbag controller.Message...
– George Wurthmann
@Georgewurthmann had already corrected, but it still didn’t work.
– Mariana
@marianac_costa And you can ensure that the execution is falling even in if?
– Jéf Bueno
@LINQ can yes, debugging he falls into it.
– Mariana