Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8987655
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:50:58+00:00 2026-06-15T21:50:58+00:00

I have a JS Dialog Box within my view. When the view is returned

  • 0

I have a JS Dialog Box within my view. When the view is returned the dialog box is maximized/open. The view also has a link and when users click on the link this dialog box opens.

I have a button within the dialog called Submit. What I am trying to do is when the modal box is open, the rest of the page elements should be blurred or disbaled. When they click on the submit button within the dialog box, it should post with the Model properties to a controller action method. I am not really good at JS syntax but how would I post back to the controller action called “Create” with a submit value of “Confirmation” within submit click?

@model RunLog.Domain.Entities.RunLogEntry
@{
    ViewBag.Title = "Create";
    Layout = "~/Views/Shared/_Layout.cshtml";

}

@using (Html.BeginForm("Create", "RunLogEntry", FormMethod.Post, new { id = "form", enctype = "multipart/form-data" }))
    {
        @Html.ValidationSummary(true)
        <div class="exception">@(ViewBag.ErrorMessage)</div>

        //xyz elements here

            <div class="bodyContent">
        <span class="leftContent">
            @Html.Label("Run Dates")
        </span><span class="rightContent"><span id="RunDatesChildDialogLink" class="treeViewLink">
            Click here to Select Run Dates</span>
            <br />
            <span id="RunDatesDisplayy"></span></span>
    </div>

    <div id="runDatestreeview" title="Dialog Title" style="font-size: 10px; font-weight: normal;
        overflow: scroll; width: 800px; height: 450px; display: none;">
        <table class="grid" style="width: 600px; margin: 3px 3px 3px 3px;">
            <thead>
                <tr>
                    <th>
                        Run Dates:
                    </th>
                </tr>
            </thead>
            <tbody>
                    @Html.EditorFor(x => x.RunDatesDisplay)
            </tbody>
        </table>
    </div>
}

JS File For DialogBox(runDates.js):

var RunDialog;
$(document).ready(function () {

    RunDialog = $("#runDatestreeview").dialog({ resizable: false, autoopen: false, height: 140, modal: true, width: 630, height: 400,
        buttons: { "Submit": function () {
            $(this).dialog("close");
        },
            Cancel: function () {
                $(this).dialog("close");
            }
        }
    });

    $('#RunDatesChildDialogLink').click(function () {
        RunDialog.dialog('open');
        $("#runDatestreeview").parent().appendTo("form");
    });

    $("#runDatestreeview").parent().appendTo("form");
});

Controller Action:

[HttpPost]
        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Create(RunLogEntry runLogEntry, String ServiceRequest, string Hour, string Minute, string AMPM,
                                     string submit, IEnumerable<HttpPostedFileBase> file, String AssayPerformanceIssues1, List<string> Replicates)
        {




**EDIT:**


var RunDialog;

$(document).ready(function () {

    RunDialog = $("#runDatestreeview").dialog({ resizable: false, autoopen: false, height: 140, modal: true, width: 630, height: 400,
        buttons: { "Continue": function () {
            var str = $("#form").serialize();

            $.ajax({
                url: "/RunLogEntry/Create",
                data: str,
                cache: false,
                type: 'POST',
                dataType: 'json',
                contentType: "application/json;charset=utf-8",
                success: function (data, status) {
                },
                error: function (xhr, ajaxOptions, thrownError) { alert('error') }
            });

        },
            Cancel: function () {
                $(this).dialog("close");
            }
        }
    });

    $('#RunDatesChildDialogLink').click(function () {
        RunDialog.dialog('open');
        $("#runDatestreeview").parent().appendTo("form");
    });

    $("#runDatestreeview").parent().appendTo("form");
});
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T21:50:59+00:00Added an answer on June 15, 2026 at 9:50 pm

    Sample To show How you can Post Data to the controller Method

    Razor Code:

    <div id="form">
            <table width="600">
                <tr>
                    <td>Select Date:</td>
                    <td>
                        <input class="txtDate" type="date" size="20"></td>
                </tr>
                <tr>
                    <td>Select Expense Type:</td>
                    <td>
                        <select class="ExpenseType">
                            <optgroup label="Room">
                                <option>Room Fare</option>
                            </optgroup>
    
                            <optgroup label="Mess">
                                <option>Monthly Mess</option>
                            </optgroup>
    
                            <optgroup label="Others">
                                <option>Bus Fare</option>
                                <option>Tapari</option>
                                <option>Mobile Recharge</option>
                                <option>Auto</option>
                            </optgroup>
                        </select></td>
                </tr>
                <tr>
                    <td>Enter Cost:</td>
                    <td>
                        <input  class="cost" type="text" size="45" /></td>
                </tr>
                <tr>
                    <td>Extra Details:</td>
                    <td>
                        <input class="extra" type="text" size="45" /></td>
                </tr>
                <tr>
                    <td>&nbsp;</td>
                    <td>
                        <button href="javascript:void(0);" onClick="saveExpense();" >Submit</button></td>
                </tr>
            </table>
        </div>
    

    JQuery Code:

       <script>
    function saveExpense()
        {
            var expenseobject = {
                date:$('.txtDate').val() ,
                type:$('.ExpenseType').val() ,
                cost: $('.cost').val(),
                extra:$('.extra').val()
    
            };
    
            $.ajax({
                url: './saveexpense',
                type: 'POST',
                contentType: 'application/json',
                data: JSON.stringify({ obj: expenseobject }),
                success: function (result) {
                    handleData(result);
    
                }
            });
    
        }
    </script>
    

    Controller:

     public ActionResult SaveExpense(Expense obj)
            {
                obj.ExpenseId = Guid.NewGuid();
                if (ModelState.IsValid)
                {
                    context.expenses.Add(obj);
                    context.SaveChanges();
                    int total=context.expenses.Sum(x => x.cost);
                    return Json(new {spent=total,status="Saved" });
    
                }
                else
                    return Json(new { status="Error"});   
            }
    

    Hope this will get you through now…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a dialog box that opens on pageload for a site. script type=text/javascript>
I have an image within an extension pages dialog box that I would like
I have a dialog box that is: JOptionPane.showMessageDialog(null,Once medicine is given, measure temperature within
Within my application I would like to have a dialog box or a form
I have a mobile web app that displays a dialog box within a position:
I have a dialog box with controls that is popped up and when a
I have a dialog box, created with the code javascript and HTML generated below.
I'm coding an MFC application in which i have a dialog box with multiple
I have created a dialog box in my MFC app as below: BackfaceControlPoints *controlpoints
I have jquery ui dialog box, and I want to resize it by the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.