Note that there are some explanatory texts on larger screens.

plurals
  1. POPassing form data from jqueryUI dialog to controller with ASP.NET MVC3
    primarykey
    data
    text
    <p>I'm new to ASP.NET MVC; something I'm having trouble with is getting data from a jqueryUI dialog form and passing it to the controller so that I can, for instance, save form input to a database. </p> <p>The method in my controller for handling this doesn't get called for some reason, despite the fact that it seems to be referenced correctly in the jquery code. Here is what I have in the view (I've obviously omitted most of the code, just putting the relevant parts here for readability):</p> <pre><code>&lt;a href="#" id="dialog_link"&gt;Open Dialog Box&lt;/a&gt; &lt;div id="dialog" title="MakeSomeSampleNote"&gt; &lt;form id="testform" method="post"&gt; &lt;input id="tbx_casenote" name="tbx_casenote" type="text" style="height:50px; width:200px;" /&gt; &lt;/form&gt; &lt;/div&gt; $("#dialog").dialog({ autoOpen: false, resizable: true, height: 210, width: 510, modal: true, buttons: { "Ok": function () { var noteval = $("#tbx-casenote").val(); $.ajax({ type: "POST", url: "@Url.Action("NoteController/SaveNote")", data: { content: tbx_casenote_val }, cache: false, dataType: "json", success: function (data) { $("#dialog").dialog("close"); } }); }, "Cancel": function () { $(this).dialog("close"); }} }); $('dialog_link').click(function () { $('#dialog').dialog('open'); return false; }); </code></pre> <p>Here is the method I'm using in the controller; when debugging, this method never gets hit after I test the dialog form and click the "Ok" button:</p> <pre><code> [HttpPost] public JsonResult SaveNote(string NoteText) { //code to save this note to database - not relevant to question return Json(new { success = true }); } </code></pre> <p>Thanks.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload