title: How to assign a form value to model before the constructor is called
body: <p>I've been struggling with this annoying problem.  I have a Model, Editor and controller:</p>
  
  <pre><code>public class TeamDetails{
     public int SeasonId{get;set;}
  
     public TeamDetails()
     {
        //need SeasonId to be populated already from form here, but it won't yet.
     }
  
     public TeamDetails(int seasonId)
          : this()
      {
        //load dropdownlist using seasonId from repository
      }
  }
  
  //Controller
  
  //get method gets seasonId from querystring.
   public ViewResult Create(int seasonId)
   {
      // calls the parameterized constructor for TeamDetails
      // which uses seasonId to populate a dropdownlist from db repo.
       var teamDetails = new TeamDetails(seasonId);
   }
  
  [HttpPost]
  public PartialViewResult Create(TeamDetails model)
  {
     // no such luxury here to call the parameterized 
     // Constructor for model. additional logic.
  }
  
  //editor
  
  @using (Ajax.BeginForm("Create", "Team", options))
  {
      @Html.ValidationSummary(true)
      @Html.HiddenFor(model =&gt; model.SeasonId)
      //additional fields
  }
  </code></pre>
  
  <p>I need to have the SeasonId from the hidden field already be populated by the time TeamDetails constructor is hit as I need that in the constructor.  However, that obviously can't happen because the constructor is called before the MVC has a chance to assign SeasonId to the object.  Any way I can get around this?</p>
  
  <p>Thanks</p>
  
  <p>Riz</p>