Search results

Show different types of toast in ASP.NET Core Toast control

08 Apr 2021 / 1 minute to read

The Syncfusion ASP.NET Core toast has the following predefined styles that can be defined using the cssClass property for achieving different types of toast:

Class Description
e-toast-success Represents a positive toast
e-toast-info Represents an informative toast
e-toast-warning Represents a toast with caution
e-toast-danger Represents a negative toast
Copied to clipboard
<div style="width:400px;margin:0 auto;">
    <ejs-toast id="element">
        <e-toast-position X="Right" Y="Bottom"></e-toast-position>
    <div class="row">
        <ejs-button id="showToast" content="Show Types" cssClass="e-btn"></ejs-button>
<script type="text/javascript">
    var toasts = [
        { title: 'Warning !', content: 'There was a problem with your network connection.', cssClass: 'e-toast-warning' },
        { title: 'Success !', content: 'Your message has been sent successfully.', cssClass: 'e-toast-success' },
        { title: 'Error !', content: 'A problem has been occurred while submitting your data.', cssClass: 'e-toast-danger' },
        { title: 'Information !', content: 'Please read the comments carefully.', cssClass: 'e-toast-info' }];
    var toastFlag = 0;
        () => {
            var toastObj = document.getElementById('element').ej2_instances[0];
   = document.body;
        }, 200);
    document.getElementById("showToast").addEventListener('click', function () {
        var toastObj = document.getElementById('element').ej2_instances[0];[toastFlag]);
        if (toastFlag === (toasts.length)) {
            toastFlag = 0;
Copied to clipboard
public class HomeController : Controller

    public ActionResult Index()
        return View();