title: MVC HTTP Post input return null
body: <p>Controller:</p>
  
  <pre><code>public ActionResult MyController()
  {
      ViewBag.DateNow = DateTime.Now.ToString("yyyy-MM-dd");
  }
  
  [HTTPPost]
  public ActionResult MyController(string fromDate)
  {
      ViewBag.DateNow = fromDate;
  }
  </code></pre>
  
  <p>View:</p>
  
  <pre><code>@using (Html.BeginForm("MyController", "Account", FormMethod.Post))
  {
      //datepicker class: bootstrap-datepicker.js
      &lt;input id="fromDate" type="text" class="datepicker" /&gt;
  
      &lt;buttontype="submit" value="Search" class="btn btn btn-primary"&gt;
          Search
      &lt;/button&gt;
  }
  </code></pre>
  
  <p>What I'm trying to achieve is before POST the data that pass into ViewBag.DateNow is the current date and it successfully bring in to the view. However when I'm trying to fill up the input form with (eg: <em>2016-05-10</em>) and click on the Search button. But seems like the fromDate string return <strong>NullReferenceException</strong>. I'm trying out with some solution online but I still can't get it right and that's why I decided to get this posted up. Thanks in advance!</p>