I have a Partial View that contains a file for downloading files. The user in this view will select a file from his workstation and click the "Download" button. A click on the download submits the form to the action method and the files are analyzed, and the same view is returned to automatically fill in several fields in the view.
Everything as it is, works great. I am adding a new requirement to an existing view that looks like this:
Demand
The user selects the file and presses the download button. After clicking the download button, a JavaScript confirmation dialog is displayed for the user, which contains two buttons before the form is submitted to the controller’s action method. These buttons are Buffer Execution Analysis and Normal Analysis. Clicking on any of these buttons will be sent according to the controller action method.
In the controller’s action method after publication, my goal is to fix which button they pressed, and based on the button pressed. I choose the parsing logic.
Problem
I created a JavaScript function that displays two buttons, but the dialog box disappears automatically and the form is sent to the controller. I would like for him not to go until I press the confirmation button.
That's what I'm doing:
The main view:
@using (Html.BeginForm("Create", "RunLogEntry", FormMethod.Post, new { id = "form", enctype = "multipart/form-data"})) { <div id="main"> @Html.Partial("_RunLogEntryPartialView", Model) </div> }
Partial view:
<button name="submit" class="art-button" type="submit" value="Upload" onclick="initUploadDailog();return false;" style="width: 100px"> Upload</button> <div id="uploadConfirmation" style="font-size: 10px; font-weight: normal; overflow: scroll; width: 800px; height: 450px; display: none;"> </div>
JS function:
function initUploadDailog(e) { currentForm = $(this).closest('form'); UploadDialog = $("#uploadConfirmation").dialog({ modal: true, width: 400, autoOpen: true, title: 'Please select parsing type for Test Completed Computation', buttons: { "Normal Parsing": function () { $("#hiddenInput").val("Normal"); alert(currentForm.innerHtml()); currentForm.submit(); }, "Buffer Parsing": function () { $("#hiddenInput").val("Buffer Run"); currentForm.submit(); } } }); }
Controller:
[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) { }