Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If you change the action method to have a <code>FormCollection</code> as the final parameter you can then pass in a <code>FormCollection</code> instance that contains all your values. The MVC framework will automatically pass in the values from the form within that parameter when running live.</p> <pre><code>public ActionResult MyMethod(FormCollection form) { // in testing you will pass in a populated FormCollection object // at runtime the framework will populate the form parameter with // the contents of the posted form } </code></pre> <p><a href="http://forums.asp.net/t/1313286.aspx" rel="nofollow noreferrer">Here</a> is a reasonable example of it being used.</p> <p><strong>Edit</strong></p> <p>Have you tried this:</p> <pre><code> /// &lt;summary&gt; /// Creates a new entry /// &lt;/summary&gt; /// &lt;returns&gt;&lt;/returns&gt; [AcceptVerbs(HttpVerbs.Post)] public ActionResult Create([Bind()]Person person, FormCollection form) { if (form["DateOfBirth"].ToString() == "") { TempData["message"] = "Please select a date of Birth"; ViewData["DateOfBirth"] = form["DateOfBirth"].ToString(); MvcValidationAdapter.TransferValidationMessagesTo( ViewData.ModelState, person.ValidationMessages); return View(); } else { if (person.IsValid()) { person.DateOfBirth = Convert.ToDateTime(form["DateOfBirth"]); personRepository.SaveOrUpdate(person); TempData["message"] = person.Firstname + " was successfully added"; return RedirectToAction( "Create", "OrderDetails", new { id = person.ID }); } else { ViewData["DateOfBirth"] = form["DateOfBirth"].ToString(); MvcValidationAdapter.TransferValidationMessagesTo( ViewData.ModelState, person.ValidationMessages); return View(); } } } </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