Note that there are some explanatory texts on larger screens.

plurals
  1. POasp.net mvc jquery $ajax passes null values to the controller
    primarykey
    data
    text
    <pre><code>$("#ftp-dialog").dialog({ autoOpen: false }); $('.ftp').live("click", function(event) { loadDialog(this, event, '#ftp-dialog'); }); }); function loadDialog(tag, event, target) { event.preventDefault(); var $loading = $('&lt;img src="../../Content/images/ajaxLoading.gif" alt="loading" class="ui-loading-icon"&gt;'); var $url = $(tag).attr('href'); var $title = $(tag).attr('title'); var $dialog = $('&lt;div&gt;&lt;/div&gt;'); $dialog.empty(); $dialog .append($loading) .load($url) .dialog({ autoOpen: false, title: $title, width: 300, modal: true, minHeight: 200, show: 'fade', hide: 'fade' }); $dialog.dialog("option", "buttons", { "Cancel": function() { $(this).dialog("close"); $(this).empty(); }, "Save": function() { var dlg = $(this); $.ajax({ url: $url, type: 'POST', data: $("#target").serialize(), success: function(response) { $(target).html(response); dlg.dialog('close'); dlg.empty(); $("#ajaxResult").hide().html('Record saved').fadeIn(300, function() { var e = this; setTimeout(function() { $(e).fadeOut(400); }, 2500); }); }, error: function(xhr) { if (xhr.status == 400) dlg.html(xhr.responseText, xhr.status); /* display validation errors in edit dialog */ else displayError(xhr.responseText, xhr.status); /* display other errors in separate dialog */ } }); } }); $dialog.dialog('open'); }; </code></pre> <p>And here is the view and the controller:</p> <pre><code>&lt;%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl&lt;jh.Models.editFtpViewModel&gt;" %&gt; &lt;%using (Html.BeginForm("EditFtp", "Pages", FormMethod.Post, new { id = "target" })) { %&gt; &lt;table&gt; &lt;tr&gt; &lt;td colspan="2"&gt; Enter Ftp Address: &lt;%=Html.TextBoxFor(x =&gt; x.ftpAddress, new {@class="text ui-widget-content ui-corner-all"})%&gt; &lt;/td&gt; &lt;td&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; Login Name:&lt;br/&gt; &lt;%=Html.TextBoxFor(x =&gt; x.loginName, new { @class = "text ui-widget-content ui-corner-all", style="width:120px;"})%&gt; &lt;/td&gt; &lt;td&gt; Password: &lt;%=Html.PasswordFor(x =&gt; x.Password, new { @class = "text ui-widget-content ui-corner-all", style="width:120px;" })%&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;input type="submit" id="button" value="Save" /&gt; &lt;%} %&gt; </code></pre> <p>Controller:</p> <pre><code>[HttpPost] public ActionResult EditFtp(editFtpViewModel model) { return View(); } </code></pre> <p>The problem is that all values what pass to the controller are null. But if I make a simple submit all is OK. Can anybody help me?</p> <p>editFTPViewModel class:</p> <pre><code>public class editFtpViewModel { public string ftpAddress { get; set; } public string loginName { get; set; } public string Password { get; set; } } </code></pre> <p>I want to pass form values to the controller according to this model.</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