Hello,
I am having some challenges using the Toast control within my ASP.NET Core app.
Could you provide a simple example of a Toast implementation where:
1/ the toast will be hidden by default when calling view ABC (GET)
2/ User clicks on button on view ABC to trigger POST version of same action ABC
3/ In ABC action (POST) in controller :
- Toast is setup with message "Error" if error in processing
- Toast is setup with message "Success" if no error
- view ABC is returned
4/ Toast message is shown in view ABC with relevant message (either "Error" or "Success" as per logic in controller (POST ABC))
Thank you.
Thanks for the quick feedback.
I was hoping for an example without using AJAX/javascript, potentially leveraging ViewData that would be set in the controller and having the Toast show the specific message (Error/Success) using ViewData when the view is returned from the POST action.
Is this possible ?
Thanks,
<ejs-toast id="element" created="oncreated" content="@ViewBag.content" cssClass="@ViewBag.css"> </ejs-toast> |
public IActionResult Index()
{
var result = true;
if (result)
{
ViewBag.content = "Success Message";
ViewBag.css = "e-toast-success";
} else
{
ViewBag.content = "Failure Message";
ViewBag.css = "e-toast-danger";
}
return View(); } |
thank you.