Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

asp mvc post not sending form data

Tags:

asp.net-mvc

i'm trying to send my form data to my ASP MVC controller but the form collection is empty. The variables in the action are bound properly. This is my Razor form

    @foreach (var recipe in Model.RecipesInCategory) {
    <form name="input" action="mycontroller/myAction/@Model.Id1/@Model.Id2" method="post">
    <fieldset>
      <table >
        <tr>
          <td>
            <input id="AddBtn" type="submit" value="Add"  />
            <select id="dayOfWeek" >
              <option value="Sunday">Sunday</option>
              <option value="Monday">Monday</option>
              <option value="Tuesday">Tuesday</option>
              <option value="Wednesday">Wednesday</option>
              <option value="Thursday">Thursday</option>
              <option value="Friday">Friday</option>
              <option value="Saturday">Saturday</option>
            </select>
          </td>
        </tr>
      </table>
    </fieldset>
    </form>
  }

and here is my controller. The two GUIDs are coming through properly, but the dow variable is always null. In fact, the Form has no entries at all.

[HttpPost]
public ActionResult myAction(Guid Id1, Guid Id2)
{
    var dow = this.Request.Form["dayOfWeek"];

Note that i have many forms on this page created in a loop. is that a problem?

like image 538
Brad Irby Avatar asked Apr 24 '12 22:04

Brad Irby


1 Answers

The browser will only POST data from form elements with name="" attributes.

like image 110
SLaks Avatar answered Nov 11 '22 13:11

SLaks