Search results

Template

The Template property can be given as the HTML element; this can be either a string or query selector.

The HTML element tag can be given as a string for the Template property.

template: "<div>Toast Content</div>"

The Template property allows getting the template content using the query selector. Here, the element ‘ID’ attribute is specified in the template.

template: "#Template"
razor
HomeController.cs
<div class="control-section">
    <div id="template_toast">
        @Html.EJS().Toast("element").TimeOut(120000).ExtendedTimeout(0).Position(p => p.X("Right").Y("Bottom")).Render()
        @Html.EJS().Button("show_toast").Content("Show Toast").CssClass("e-btn").Render()
    </div>
    <br /><br />
    <div id='result'></div>
</div>
    </div>
<script id="template_toast_ele" type="text/x-template">
    <div id='template_toast' style="display: none">
        <div class="horizontal-align">
            <div class='toast-content'>
                <div class='toast-title'>
                    Weekend Alarm
                </div>
                <div class='toast-message'>
                    With traffic, its likely to take 45 minutes to get to jenny's 24th Birthday Bash at Hillside Bar, 454 E.
                    Olive Way by 10:00PM
                </div>
            </div>
        </div>
        <img src="http://npmci.syncfusion.com/development/demos/src/toast/resource/map.jpg" width="100%" height="70%">
    </div>
</script>

<script type="text/javascript">
    setTimeout(
        () => {
            var toastObj = document.getElementById('element').ej2_instances[0];
            toastObj.target = document.body;
            toastObj.show({ template: document.getElementById('template_toast_ele').innerHTML });
        }, 1000);
    document.getElementById("show_toast").addEventListener('click', function () {
        var toastObj = document.getElementById('element').ej2_instances[0];
        toastObj.show();
    });
</script>
<style>
    #loader {
        color: #008cff;
        height: 40px;
        left: 45%;
        position: absolute;
        top: 45%;
        width: 30%;
    }

    #snooze,
    #dismiss {
        background-color: #fff;
    }

    body > #element .e-toast {
        width: 400px !important;
    }

    .toast-template-section #reminder {
        text-align: center;
        margin: 15px;
    }

    #toast_custom .e-toast-template {
        display: inline-flex;
    }

    #template_toast .toast-icons {
        font-size: 35px;
        height: auto;
        margin: auto;
    }

        #template_toast .toast-icons.e-alarm::before {
            content: "\e702";
        }

    #template_toast .horizontal-align {
        display: inline-flex;
        flex-direction: row;
        width: 100%;
    }

    #template_toast .horizontal-align,
    #template_toast #snoozedropDown,
    #template_toast .snooze,
    #template_toast .snoozeBtn {
        margin: 10px 0;
    }

        #template_toast .horizontal-align .toast-content .toast-title {
            font-weight: 500;
        }

        #template_toast .horizontal-align .toast-content .toast-message {
            opacity: 0.4;
        }

        #template_toast .horizontal-align .toast-content {
            display: inline-flex;
            flex: 1;
            flex-direction: column;
            margin-left: 10px;
        }
</style>
public ActionResult Toast()
{
    return View();
}

Output be like the below.

Alt text

See Also