Note that there are some explanatory texts on larger screens.

plurals
  1. POFormcollection doesn't extract data from form MVC
    text
    copied!<p>I have trouble with formcollection.</p> <p>I have some form in view, and two submit buttons both with unique name="". On debug I get on controller in formcollection all data except "name" of submitted button... I don't know why, 'cos I use this in other forms and there it works good. So I look at the code, but I couldn't find any differencies in using formcollection on not working formcol and working formcol. I tried rename buttons, move them, add referencies which I thought that could help... Nothing. On every submit skip my condition because it give me back only "false" and formcollection my "upload" or "save" button on onclick doesn't contain... </p> <p>So I would like to ask you for help with this. Can you tell me where could be an error? Thanks to all!</p> <p>This is in controller:</p> <pre><code>[HttpPost] public ActionResult EditUser(EditUserVM model, int id, FormCollection c) { //c["upload"] is everytime set to null, 'cos c does't contain it if (c["upload"] != null) { //.... some code return RedirectToAction("Index", "Home"); } if (ModelState.IsValid) { //.... next code } return View("EditUser", model); } </code></pre> <p>This is in View:</p> <pre><code> @model PrukazOnline.ViewModels.EditUserVM @{ ViewBag.Title = "EditUser"; Layout = "~/Views/Shared/_Layout.cshtml"; } &lt;script type="text/javascript" src="@Url.Content("~/Scripts/jquery.validate.min.js")"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")"&gt;&lt;/script&gt; @using (Html.BeginForm("EditUser", "User", null, FormMethod.Post, new { @class = "form-horizontal", id = "formstep", enctype = "multipart/form-data" })) { @*Here is some code - @Html.TextBoxFor(x =&gt; x.something) and @Html.ValidationMessageFor(x =&gt; x.something) - all of these are in formcollection*@ . . . . &lt;div&gt; &lt;input type="submit" value="Nahrát" class="upl" name="upload" id="upload" /&gt; &lt;/div&gt; &lt;div class="submit_buttons"&gt; &lt;input type="submit" name="save" id="save" value="Uložit" /&gt; &lt;/div&gt; } </code></pre>
 

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