title: MVC model binding to nested classes
body: <p>When I try and create a new 'Flow' class the nested classes ('Action') always come back as null in the controller</p>
  
  <p>So I have classes within classes like so:</p>
  
  <pre><code>public class Flow
  {
      private Action actionField
      private string nameField
      private bool enabledField
      ...
  }
  
  public class Action
  {
      private ActionSchedule actionScheduleField
      private ActionParameter actionParameterField
      private nameField
  }
  public class ActionSchedule
  ...
  </code></pre>
  
  <p>And a single create view for a 'Flow'</p>
  
  <pre><code>@model ProjectZeus.Models.Flow
  @using (Html.BeginForm())
  {
  @Html.AntiForgeryToken()
  @Html.ValidationSummary(true)
  
     @Html.TextBoxFor(model =&gt; model.name, new { @placeholder = "Flow name" })
     @Html.ValidationMessageFor(model =&gt; model.name)
  
  
     @Html.LabelFor(model =&gt; model.enabled)
  
     @Html.EditorFor(model =&gt; model.enabled)
     @Html.ValidationMessageFor(model =&gt; model.enabled)
  
  @Html.Partial("FlowAction")
  ...
  </code></pre>
  
  <p>and then partial views for each of the subclasses</p>
  
  <pre><code>@model ProjectZeus.Models.FlowAction
  
      @Html.TextBoxFor(model =&gt; model.name, new { @placeholder = "Action name" })
      ...
  </code></pre>
  
  <p>I've tried creating instances of the classes and calling the view - error,</p>
  
  <p>I've tried creating instances of the classes in the views themselves - error,</p>
  
  <p>I've tried not using PartialViews:</p>
  
  <pre><code>@Html.TextBoxFor(model =&gt; model.action.name, new { @placeholder = "Action name" })
  </code></pre>
  
  <p>I've googled and googled and googleedddd but with no luck, help please!?</p>
  
  <p>Edit:</p>
  
  <p>Implementing a customer model binder seems like overkill. This page describes the same problem but the solution code won't compile for me ‘The name ‘helper’ does not exist in the current context’? - <a href="http://danielhalldev.wordpress.com/2013/08/23/partial-views-and-nested-mvc-model-binding/" rel="noreferrer">http://danielhalldev.wordpress.com/2013/08/23/partial-views-and-nested-mvc-model-binding/</a></p>
  
  <p>Edit2:</p>
  
  <p>I changed the model defintions for brevity - the model is actually auto generated from an xsd: </p>
  
  <pre><code>/// &lt;remarks/&gt;
  [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.33440")]
  [System.SerializableAttribute()]
  [System.Diagnostics.DebuggerStepThroughAttribute()]
  [System.ComponentModel.DesignerCategoryAttribute("code")]
  [System.Xml.Serialization.XmlTypeAttribute(AnonymousType = true)]
  public partial class D53ESBFlow
  {
  
      private D53ESBFlowAction actionField;
  
      [Required]
      private string nameField;
  
      ...
  
      private bool enabledField;
  
      /// &lt;remarks/&gt;
      public D53ESBFlowAction action
      {
          get
          {
              return this.actionField;
          }
          set
          {
              this.actionField = value;
          }
      }
      /// &lt;remarks/&gt;
      [System.Xml.Serialization.XmlAttributeAttribute()]
      public string name
      {
          get
          {
              return this.nameField;
          }
          set
          {
              this.nameField = value;
  </code></pre>
  
  <p>Edit 3 (bump):</p>
  
  <p>It looks like the 'binder'is creating a property and not a class object?
  <img src="https://i.stack.imgur.com/KQ8Ep.png" alt="whereRu"></p>