title: Passing parameters from view to controller in mvc4
body: <p>I have a confusing issue with passing parameters from a view to controller in MVC 4. The problem is that I have created a view and I have created the following code :</p>
  
  <pre><code> &lt;% using (Html.BeginForm("DisplaySummaryFigures", "Report", FormMethod.Post, new { Par1 = "some", Par2 = "some" }))
    { %&gt;
  
      &lt;%: Html.ValidationSummary(true)%&gt;
  
      &lt;table id="tblInsertDates"&gt;
          &lt;tr&gt;
              &lt;th&gt;
                  &lt;asp:Label ID="Label1" runat="server" Text="lblStratDate"&gt; Insert the Start Date:&lt;/asp:Label&gt;
                  &lt;input type="date" name="TxtStartDate" value="" /&gt;
              &lt;/th&gt;
              &lt;th&gt;
                  &lt;asp:Label ID="Label2" runat="server" Text="lblEndDate" Style="padding-left: 5px"&gt;Insert the End Date:&lt;/asp:Label&gt;
                  &lt;input type="date" name="TxtEndDate" value="" /&gt;&lt;br /&gt;
              &lt;/th&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;
                  &lt;input type="submit" name="SubmitDates" value="Enter" /&gt;&lt;br /&gt;
  
              &lt;/td&gt;
  
          &lt;/tr&gt;
      &lt;/table&gt;
  </code></pre>
  
  <p>inside my controller, I have passed them as the following:</p>
  
  <pre><code>[HttpGet]
      public ActionResult ExportSummaryFiguresToCSV()
  
      [HttpPost]
      public ActionResult ExportSummaryFiguresToCSV(DateTime TxtStartDate, DateTime TxtEndDate)
      {
  
  
          StringWriter sw = new StringWriter();
          DateTime dtStartDateFromUser = TxtStartDate;
          DateTime dtEndDateFromUser = TxtEndDate;
  </code></pre>
  
  <p>when I run the program is returns the following Error :( :</p>
  
  <pre><code>The parameters dictionary contains a null entry for parameter 'TxtStartDate' of non-nullable type 'System.DateTime' for method 'System.Web.Mvc.ActionResult TotalSharepointDetails(System.DateTime, System.DateTime)' in 'SalesStaticsWebSite.Controllers.ReportController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter.
  </code></pre>
  
  <p>Parameter name: parametersere</p>
  
  <p>Any ideas please ??
  Thanks in Advance </p>