Search results

Read all values of Dialog on button click in ASP.NET MVC Dialog control

30 Nov 2021 / 1 minute to read

You can read the dialog element values by binding the action handler to the footer buttons. The Buttons property provides the options to bind events to the action buttons. For detailed information about buttons , refer to the footer section. In the below sample, value of input elements within the dialog has been checked in the footer button click event and send the values as the content of confirmation dialog.

Copied to clipboard
@using Syncfusion.EJ2.Popups

<div id="target" class="col-lg-12 control-section">
    @Html.EJS().Dialog("dialog").AnimationSettings(a=>a.Effect(DialogEffect.Zoom)).Header("User Details").ShowCloseIcon(true).Width("400px").Target("#target").Buttons(btn=> {

        <div class="form-group"><label for="name">Name:</label><input type="name" value="" class="form-control" id="name"></div>
        <div class="form-group"><label for="email">Email Id:</label><input type="email" value="" class="form-control" id="email"></div>
        <div class="form-group"><label for="contact">Contact Number:</label><input type="contact" class="form-control" id="contact"></div>
        <div class="form-group"><label for="address">Address:</label><textarea class="form-control" rows="5" id="address"></textarea></div>
    @Html.EJS().Dialog("model_dialog").AnimationSettings(a => a.Effect(DialogEffect.Zoom)).Header("User Details").Visible(false).ShowCloseIcon(true).IsModal(true).Target("#target").Buttons(btn=> {

<link href="" rel="stylesheet">
    document.getElementById("normalbtn").onclick = function () {
        var dialogObj = document.getElementById("dialog").ej2_instances[0];;
    function dlgButtonClick() {
        var dialogObj = document.getElementById("model_dialog").ej2_instances[0];
    function returnClick() {
        var dialogObj = document.getElementById("model_dialog").ej2_instances[0];
        var dialogObj1 = document.getElementById("dialog").ej2_instances[0];;
    function submitButtonClick() {
        var dialogObj = document.getElementById("dialog").ej2_instances[0];
        var dialogObj1 = document.getElementById("model_dialog").ej2_instances[0];
        dialogObj1.content = getDynamicContent();;
    function getDynamicContent() {
        var input = document.getElementById('dialog').querySelector('#name');
        var email = document.getElementById('dialog').querySelector('#email');
        var contact = document.getElementById('dialog').querySelector('#contact');
        var address = document.getElementById('dialog').querySelector('#address');
        var template = "<div class='row'><div class='col-xs-6 col-sm-6 col-lg-6 col-md-6'><b>Confirm your details</b></div>" +
            "</div><div class='row'><div class='col-xs-6 col-sm-6 col-lg-6 col-md-6'><span id='name'> Name: </span>" +
            "</div><div class='col-xs-6 col-sm-6 col-lg-6 col-md-6'><span id='nameValue'>" + input.value + "</span> </div></div>" +
            "<div class='row'><div class='col-xs-6 col-sm-6 col-lg-6 col-md-6'><span id='email'> Email: </span>" +
            "</div><div class='col-xs-6 col-sm-6 col-lg-6 col-md-6'><span id='emailValue'>" + email.value +
            "</span></div></div><div class='row'><div class='col-xs-6 col-sm-6 col-lg-6 col-md-6'>" +
            "<span id='Contact'> Contact number: </span></div><div class='col-xs-6 col-sm-6 col-lg-6 col-md-6'>" +
            "<span id='contactValue'>" + contact.value + " </span></div></div><div class='row'><div class='col-xs-6 col-sm-6 col-lg-6 col-md-6'>" +
            "<span id='Address'> Address: </span> </div><div class='col-xs-6 col-sm-6 col-lg-6 col-md-6'><span id='AddressValue'>" + address.value + "</span></div></div>"
        return template;
    .control-section {
        padding-left: 10px;

    #target {
        height: 100%;
        min-height: 350px;

    #model_dialog {
        margin: 20px;

    .row {
        padding: 10px 3px;
Copied to clipboard
public class HomeController : Controller
    public class ButtonModel
        public string content { get; set; }
        public bool isPrimary { get; set; }


    // GET: RTL
    public ActionResult Index()
        ViewBag.DialogButtons = new ButtonModel() { isPrimary = true, content = "Submit" };
        ViewBag.SubmitButtons1 = new ButtonModel() { content = "YES", isPrimary = true };
        ViewBag.SubmitButtons2 = new ButtonModel() { content = "NO" };
        return View();