title: MVC4: Model's properties are null
body: <p>My MVC4 application has a ListBox and several buttons. When I select an item in the ListBox and press the Delete button and hit the breakpoint in the Delete() method, for some reason all properties of the model object passed to the Delete() method are null. Could you please explain this to me?</p>
  
  <p>Here is some code:</p>
  
  <p>In the model:</p>
  
  <pre><code>public class EdiFileModel
  {
      public SelectList EdiFileNames { get; set; }
      public string SelectedEdiFilename { get; set; }
  ...
  }
  </code></pre>
  
  <p>In the view:</p>
  
  <pre><code>@model EdiSimulatorWebSender.Models.EdiFileModel
  ...
  
  @Html.ListBoxFor(m =&gt; m.SelectedEdiFilename, new SelectList(Model.EdiFileNames, "Value", "Text", Model.EdiFileNames.SelectedValue), new { @Id = "EdiFileNames", @style = "width:Auto;height=Auto;maxHeight:200;" })
  
  &lt;form action="" method="post"&gt;
   &lt;input type="submit" value="Send" name="action:Send" /&gt;
   &lt;input type="submit" value="Delete" name="action:Delete" /&gt;
   &lt;input type="submit" value="Refresh" name="action:Refresh" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>In the controller:</p>
  
  <pre><code>    [HttpPost]
      [MultipleButton(Name = "action", Argument = "Delete")]
      [ActionName("Index")]
      public ActionResult Delete(EdiFileModel ediFileModel)
      {
          string selectedFileName = ediFileModel.SelectedEdiFilename;
          ...
      }
  </code></pre>
  
  <p><strong>ADDED:</strong></p>
  
  <p>I would like also to be able to get on postback not only the Id of the selected item, but the list itself, so that I could use the Id to get the selected item. In my case, the ListBox contains names of the files in a particular folder. I want to be able to select a file, press the Delete button and delete the file. In the Delete() method, I get back the Id, but I would like to get also EdiFileNames.</p>
  
  <p>This is the latest code I have:</p>
  
  <p>Model:</p>
  
  <pre><code>public class EdiFileModel
  {
      //public SelectList EdiFileNames { get; set; }
      public Dictionary&lt;string, string&gt; EdiFileNames { get; set; }
      public string SelectedEdiFileId { get; set; }
      public string ResponseContent { get; set; }
  }
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>    public ActionResult Index()
      {
          var ediFileModel = new EdiFileModel {EdiFileNames = GetAllEdiFiles()};
          return View(ediFileModel);
      }
  
      [HttpPost]
      [MultipleButton(Name = "action", Argument = "Delete")]
      [ActionName("Index")]
      public ActionResult Delete(EdiFileModel ediFileModel)
      {
          string selectedFileId = ediFileModel.SelectedEdiFileId;
  
          string selectedFileFullName = Path.Combine(SourcePath, ediFileModel.EdiFileNames[selectedFileId]);
          System.IO.File.Delete(selectedFileFullName);            
          return View(ediFileModel);
      }
  </code></pre>
  
  <p>View:</p>
  
  <pre><code>@using (Html.BeginForm())
  {
      var ediFilesSelectList = new SelectList(Model.EdiFileNames, "Key", "Value", Model.SelectedEdiFileId);
      @Html.ListBoxFor(m =&gt; m.SelectedEdiFileId, ediFilesSelectList, new {@Id = "EdiFileNames", @style = "width:Auto;height=Auto;maxHeight:200;"})
      @Html.HiddenFor(model =&gt; model.EdiFileNames)
  </code></pre>