Search results

Template

In Dialog the template support is provided to the header, footer and content sections. So any text or HTML content can be appending in these sections.

The Dialog header content can be provided through the header property, and it will allow both text and any HTML content as a string. Also in header, close button is provided as built-in support, and this can be enabled through the showCloseIcon property.

The Dialog footer can be enabled by adding built-in buttons or providing any HTML string through the footerTemplate.

The buttons and footerTemplate properties can’t be used at the same time.

Content

The Dialog content can be provided through the content property, and it accepts both text and HTML string as content by using e-content-template tag helper.

The below example demonstrates the usage of header, footer and content templates in the Dialog control.

tagHelper
Footer.cs
@section ControlsSection{

    <div id="target" class="col-lg-12 control-section" style="height:100%">
        <ejs-button id="targetButton" e-ripple="true" content="OPEN DIALOG"></ejs-button>
        <ejs-dialog id="dialog" open="dialogOpen" height="85%" width="45%" target="#target" close="dialogClose" header="<img class='img2' src='./../css/Dialog/images/1.png'><div title='Nancy' class='e-icon-settings e-icons'' style='padding: 3px;'>Nancy</div>"
                    showCloseIcon="true" content="<div class='dialogContent'><span class='dialogText'>Greetings Nancy! When will you share me the source files of the project?</span></div>" created="onLoad" footerTemplate="<input id='inVal' class='e-input' type='ext' placeholder='Enter your message here!'/><button id='sendButton' class='e-control e-btn e-primary' data-ripple='true'>Send</button>">
        </ejs-dialog>
    </div>
}

<script>
    var validText;
    document.getElementById('targetButton').onclick = function () {
        var dialogObj = document.getElementById('dialog').ej2_instances[0];
        dialogObj.show();
    };
    function onLoad() {
        (document.getElementById('inVal')).onkeydown = function (e) {
            if (e.keyCode === 13 && validText != "") {
                updateTextValue();
            }
            };
        (document.getElementById('sendButton')).onkeydown = function (e) {
            if (e.keyCode === 13 && validText != "") {
                updateTextValue();
            }
        };
        document.getElementById('sendButton').onclick = function (e) {
            updateTextValue();
        }
    }      
    function updateTextValue() {
        var enteredVal = document.getElementById('inVal');
        var dialogTextElement = document.getElementsByClassName('dialogText')[0];
        var dialogTextWrap = document.getElementsByClassName('dialogContent')[0];
        if (enteredVal.value !== '') {
            dialogTextElement.innerHTML = enteredVal.value; enteredVal.value = '';
        }
    }

</script>
public ActionResult Footer()
{
    return View();
}

Output be like the below.

dialog

See Also