6
looking for a solution I found a way in the link Controller message to view
But my problem is that nothing is shown. I don’t know if it’s because I don’t have an action in the View but the message doesn’t appear.
The structure is mounted in this way (the base structure of the previous link has been maintained and mounted practically equal):
Controller
public ActionResult Relatorios()
{
ViewBag.Message = "Mensagem";
ViewBag.TipoUser = 1;
this.FlashInfo(this, "Mensagem de Informação.");
this.FlashWarning("Mensagem de Aviso.");
this.FlashError("Mensagem de Erro.");
}
Inside the View I only have the following code:
@model dynamic
@{
ViewBag.Title = "Relatórios";
Layout = "~/Areas/Admin/Views/Shared/_Layout.cshtml";
}
Report Management
Within _Layout
placed within the following segment
<div class="container-fluid" style="margin-left: 10px; margin-right:5px; margin-bottom: 10px; margin-top: 10px">
@Flash.FlashMessage(TempData)
<div id="flash">
</div>
@RenderBody()
<hr/>
<footer style="margin-top: 10px">
<p>© @DateTime.Now.Year - Empresa</p>
</footer>
</div>
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/bootstrap")
@Scripts.Render("~/bundles/jqueryval")
@Scripts.Render("~/bundles/jqueryui")
@Scripts.Render("~/bundles/site")
@Scripts.Render("~/bundles/modernizr")
@Scripts.Render("~/bundles/inputmask")
@Scripts.Render("~/bundles/maskedinput")
@RenderSection("scripts", required: false)
</body>
</html>
Someone can help me?
You want to write the content of
ViewBag.Message
on your page? if it is just put@ViewBag.Message
in the view. I don’t quite understand what you want.– Ricardo
In fact, I set up the structure offered by the link attached, everything works "apparently" by debug has no error, but also does not present the message. I do not know if it is because the controller does not have an action or Submit but I did a test including this and still did not present the message.
– Ricardo Facincani
Did you inspect the HTML content to see if the message was written to it? It might just be a display problem.
– Leonel Sanches da Silva
Do what @Gypsy said. If you still don’t find it, you can do another test, you see that
@DateTime.Now.Year
there at the end of Layout? Do you see it in HTML? If you see it, put the@ViewBag.Message
right next to it. The message should appear pasted on the date, at least it will give you a light on how the view works– Ricardo
When I put Viewbag.Message next to @Datetime it worked, but the Flashinfo method for example does not appear. Imagine that I have several actions inside the controller and at the end I would like to present a message like Alert with the information Flashinfo ("Process performed successfully"), inside the controller not passing the Viewbag or something similar but presenting the message, so I saw the topic and did the implementation.
– Ricardo Facincani
Trying to resolve the situation, I tried to take the <div = "></div" to the view and Flash.Flashmessage(Tempdata) to the view by removing it from _Layout and it didn’t work either. Nothing is shown. It’s like he’s ignoring the helper’s javascript. I think !
– Ricardo Facincani
Doing the debug, I could notice that it enters Flash.cshtml, tests the content and passes stating that it is not null, processes the javascript and returns to view, then it processes the _Layout and when finished it shows nothing.
– Ricardo Facincani