We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to submit for within ejDialog?

Thread ID:

Created:

Updated:

Platform:

Replies:

121380 Dec 8,2015 11:49 AM UTC Dec 28,2015 05:22 AM UTC ASP.NET MVC 7
loading
Tags: Dialog
Manish
Asked On December 8, 2015 11:49 AM UTC

Hi,

I have use ejDialog box in ASP.net MVC. I tried to submit form with the ej dialog. But it is unable to submit.

My Snippet :
//This is my partial view
@using (Html.BeginForm("List", "PurchaseRequest", FormMethod.Post))
{
    <div class="row" style="width: 100%; padding-bottom: 5px;">
        <div class="col-md-12" style="padding-right:0px;">
            <span id="message"></span>
        </div>
    </div>
    <div class="row" style="width: 100%; padding-bottom: 5px;">
        <div class="col-md-12" style="padding-right:0px;">
            @Html.EJ().Button("Ok").Type(ButtonType.Submit).Text("Ok").Size(ButtonSize.Normal).ShowRoundedCorner(true).ContentType(ContentType.ImageTextImage).PrefixIcon("e-information")
        </div>
    </div>
}

Upon clicking on Ok Button, I am expecting form to be posted on "PurchaseRequest / List".

Can you guide me on this?

Piramanayagam Ramakrishnan [Syncfusion]
Replied On December 9, 2015 01:22 PM UTC

Hi Manish,
 
Thanks for using Syncfusion Products.
We are not able to reproduce the issue (How to submit form within ejDialog?). In our side, dialog is working properly with your given code.
For your reference, we have attached a sample to showcase that the form submit is working properly within the ejDialog.
Sample Location: Dialog Sample
If still you face the same issue kindly get back to us with more information or please revert back the provided sample based on your application along with the replication procedure to reproduce the issue at our end also please update us about version of Essential Studio that your currently using this would be helpful for us to identify the issue and provide a solution at the earliest.
 
Regards,
Piramanayagam R

Manish
Replied On December 10, 2015 05:48 AM UTC

Hi,

I tried your sample project, It is working in your project. It also working in my project. but the height / width is improper. Please see the screenshot. I observe that it is creating two dialog box.



I also observed that, in your project it is creating two dialog box, 1 behind the other. If you move your dialog you will see two dialog box.



Supporting Data :

Parital View :

@Html.EJ().Dialog("MessageBox").Title("Expense Reimbursement System").Width(800).IsResponsive(true).Height(300).ContentTemplate(@<div>
    @using (Html.BeginForm("List", "PurchaseRequest", FormMethod.Post))
    {
        <div class="row" style="width: 100%; padding-bottom: 5px;">
            <div class="col-md-12" style="padding-right:0px;">
                <span id="message"></span>
            </div>
        </div>
        <div class="row" style="width: 100%; padding-bottom: 5px;">
            <div class="col-md-12" style="padding-right:0px;">
                @Html.EJ().Button("Ok").Type(ButtonType.Submit).Text("Ok").Size(ButtonSize.Normal).ShowRoundedCorner(true).ContentType(ContentType.ImageTextImage).PrefixIcon("e-information")
            </div>
        </div>
    }
</div>)

HTML :
    <div class="container">

    </div>

Ajax Call :

 $.ajax({
                        url: "/PurchaseRequest/MessageBox",
                        type: "POST",
                        success: function (e) {
                            debugger;
                            $('.container').append($(e));
                            //$("#message").val(data.Message);
                            ej.widget.init($('.container'));
                        }
                    });


Francis Paul Antony Raj [Syncfusion]
Replied On December 11, 2015 02:21 PM UTC

Hi Manish,


Sorry for the inconvenience.


#1) in your project it is creating two dialog box, 1 behind the other. If you move your dialog you will see two dialog box.

The sample we have provided, the control is rendered in the div with class name “container”. Since div with “container” class is already existing in layout page, so that dialog control is created twice. Now we have modified the sample. Please refer to the following link.

http://www.syncfusion.com/downloads/support/forum/121380/ze/dialogsample-196822790


#2) the height / width is improper.

The height and width of the dialog component is set as per the property values in the sample. Please check with the sample.

To know more about dialog control, Please refer to the following getting started link.

http://help.syncfusion.com/aspnetmvc/dialog/overview

For dialog properties, methods, and events, refer to the below link.

http://help.syncfusion.com/js/api/ejdialog


Regards,

Francis Paul A


Manish
Replied On December 14, 2015 04:46 AM UTC

Hi Francis,

Thanks for your support. I know we can set height and width but after setting height and width it was not working, so I rollback your changes and write a different code, which works fine to me.
Now the problem is dialog box does not submit form.
I am rendering message box with this line.


@Html.EJ().Dialog("MessageBox").Title("Expense Reimbursement System").Width(800).ShowOnInit(false).IsResponsive(true).ContentTemplate(@<div>@(Html.Partial("MessageBox"))</div>)

which is I guess is true.

Let me give you supporting data.

My Main .cshtml file:


@model ERSCore.Models.PurchaseRequestModel
@{
    ViewBag.Title = "Create New Purchase Request";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<style type="text/css">
    .body {
        font-family: Segoe UI;
    }
</style>
<script type="text/javascript">
    function PurchaseRequestModel() {
        this.EmployeeID = parseInt("0");
        this.Lines = new Array();
    }
    function LineModel() {
        this.Amount = parseFloat("100.00");
        this.FromCountry = "IN";
        this.ToCountry = "";
        this.FromState = "";
        this.ToState = "";
        this.FromCity = "";
        this.ToCity = "";
        this.FromDate = "";
        this.ToDate = "";
        this.Remark = "";
        this.Attachment = "";
        this.ExpenseType = "";

        this.ExpenseText = "";
        this.FromCountryText = "";
        this.ToCountryText = "";
        this.FromStateText = "";
        this.ToStateText = "";
    }
    var LineItems = new Array();

    function AddExpense() {
        eDialog = $("#AddExpenseDialog").data("ejDialog");
        if (eDialog.model)
            eDialog.open();
    }

    function SubmitRequst() {
        var pr = new PurchaseRequestModel();
        pr.EmployeeID = $("#EmployeeID").val();
        pr.Lines = LineItems;
        $.ajax({
            url: '/PurchaseRequest/CreateNew',
            data: JSON.stringify({ model: pr }),
            type: 'POST',
            contentType: 'application/json',
            error: function (a, b, c) {
                debugger;
            },
            success: function (data, b, c) {
                if (data.Result == "0") {
                    eDialog = $("#MessageBox").data("ejDialog");
                    if (eDialog.model)
                        eDialog.open();
                    //$.ajax({
                    //    url: "/PurchaseRequest/MessageBox",
                    //    type: "POST",
                    //    success: function (e) {
                    //        debugger;
                    //        $('.container').append($(e));
                    //        //$("#message").val(data.Message);
                    //        ej.widget.init($('.container'));
                    //    }
                    //});
                }

            }
        });
    }
</script>
@using (Html.BeginForm("CreateNew", "PurchaseRequest", FormMethod.Post))
{
    @Html.AntiForgeryToken()
    <h2 style="color:blue;">Create New Travel Request</h2><hr style="color:blue;" />
    <div class="row" style="width: 100%; padding-bottom: 5px;">
        <div class="col-md-3" style="padding-right:0px;">
            Employee Code / Name
        </div>
        <div class="col-md-1" style="padding-right:0px;">
            @Html.TextBoxFor(model => model.EmployeeID, new { @class = "form-control  input-sm" })
        </div>
        <div class="col-md-2" style="padding-right:0px;">
            @Html.TextBoxFor(model => model.EmployeeName, new { @class = "form-control  input-sm", @readonly = "readonly" })
        </div>
        <div class="col-md-3" style="padding-right:0px;">
            No.
        </div>
        <div class="col-md-3" style="padding-right:0px;">
            <div style="float:right;">
                @Html.TextBoxFor(model => model.DocNum, new { @class = "form-control  input-sm", @readonly = "readonly", @style = "width:170px" })
            </div>
            <div style="float:left;">
                @Html.DropDownListFor(model => model.Series, new SelectList(Model.SeriesList, "Code", "Name"), new { @class = "form-control  input-sm", @style = "width:100%" })
            </div>
        </div>
    </div>
    <div class="row" style="width: 100%; padding-bottom: 5px;">
        <div class="col-md-3" style="padding-right:0px;">
          Project
        </div>
        <div class="col-md-3" style="padding-right:0px;">
            @Html.DropDownListFor(model => model.ProjectCode, new SelectList(Model.Projects, "Code", "Name", "Extra1", 1), new { @class = "form-control  input-sm" })
        </div>
        <div class="col-md-3" style="padding-right:0px;">
            Status
        </div>
        <div class="col-md-3" style="padding-right:0px;">
            @Html.DropDownListFor(model => model.StatusCode, new SelectList(Model.StatusList, "Code", "Name"), new { @class = "form-control  input-sm",   @disabled="disabled" })
        </div>
    </div>
    <hr style="color:blue;" />
    <div class="row" style="width: 100%; padding-bottom: 5px;border:0px solid red;" align="right">
        <div class="col-md-10" style="padding-right:0px;" align="left">
            <h4 style="color:blue;">Request Details</h4>
        </div>
        <div class="col-md-1" style="padding-right: 0px; line-height: 39.8px;">
            @Html.EJ().Button("button_normal").ClientSideEvents(evt => evt.Click("AddExpense")).Type(ButtonType.Button).Text("Add").Size(ButtonSize.Normal).ShowRoundedCorner(true).ContentType(ContentType.ImageTextImage).PrefixIcon("e-collaps")
        </div>
        <div class="col-md-1" style="padding-right:0px;line-height:39.8px;">
            @Html.EJ().Button("uxSave").ClientSideEvents(evt => evt.Click("SubmitRequst")).Type(ButtonType.Button).Text("Submit").Size(ButtonSize.Normal).ShowRoundedCorner(true).ContentType(ContentType.ImageTextImage).PrefixIcon("e-save")
        </div>
    </div>
    <div class="row" style="width: 100%; padding-bottom: 5px;" align="right">
        @{Html.EJ().Dialog("AddExpenseDialog").Title("Add Expense").EnablePersistence(true).Width(800).ShowOnInit(false).EnableModal(true).ContentTemplate(@<div>@(Html.Partial("AddExpense", Model.Lines[0]))</div>).Render();}
    </div>
    <div id="details">
        <div class="row" style="width: 100%; padding-bottom: 5px;height:40px;background-color:lightblue;border:1px solid gray; line-height:40px;">
            <div class="col-md-3" style="padding-right:0px;">
               Expense Type
            </div>
            <div class="col-md-7" style="padding-right:0px;">
                Description
            </div>
            <div class="col-md-2" style="padding-right:0px;">
                Amount
            </div>
        </div>
    </div>
    <div class="container">
        @Html.EJ().Dialog("MessageBox").Title("Expense Reimbursement System").Width(800).ShowOnInit(false).IsResponsive(true).ContentTemplate(@<div>@(Html.Partial("MessageBox"))</div>)
    </div>
}

My Partial View:

@using (Html.BeginForm("List", "PurchaseRequest", FormMethod.Post))
{
    <div class="row" style="width: 100%; padding-bottom: 5px;">
        <div class="col-md-12" style="padding-right:0px;">
            <span id="message">test</span>
        </div>
    </div>
    <div class="row" style="width: 100%; padding-bottom: 5px;">
        <div class="col-md-12" style="padding-right:0px;">
            @Html.EJ().Button("Ok").Type(ButtonType.Submit).Text("Ok").Size(ButtonSize.Normal).ShowRoundedCorner(true).ContentType(ContentType.ImageTextImage).PrefixIcon("e-information")
        </div>
    </div>
}





Francis Paul Antony Raj [Syncfusion]
Replied On December 16, 2015 10:47 AM UTC

Hi Manish,


We have analyzed your query. We are unable to reproduce the reported issue “dialog box does not submit the form”. We have prepared the sample based on your code snippet. In the sample, dialogbox submit the form properly and form post back values are obtained in the controller action. Please check with the sample in the below location.

http://www.syncfusion.com/downloads/support/forum/121380/ze/DialogControl-1462693548


If still persists any problem while submitting the dialog, could you please revert back the sample with your issue? This will help us to provide the better solution.


Regards,

Francis Paul A


Manish
Replied On December 24, 2015 08:57 AM UTC

Hi Francis Paul A,

Thanks a ton for all your support.
I have resolved this issue, issue was cause because there were two BeginForm after rended html,
1. Is from mail.cshtml
2. Is from PartialView.cshtml.

After removing BeginForm from mail.cshtml file, It is working fine.

You can close this thread.

Rekha J [Syncfusion]
Replied On December 28, 2015 05:22 AM UTC

Hi Manish,

Thank you for your update.
Please let us know if you need any further assistance on this. As always, we will be happy to assist you.


Regards,

Rekha.


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;