title: Partial View returning Null model ASP.NET MVC 4
body: <p>Within my MainView, I was able to render all the "TaskComment"(model) using _GetForTask partial view. Then within my _GetForTask partial view, I was able to render _TaskCommentForm and successfull passed a new instance of TaskComment model. However, whenever I click the "Submit" button in the _TaskCommentForm partial view, it always returns null. What am I missing here? Thanks a lot.</p>
  
  <p>"TaskComment" model</p>
  
  <pre><code>public partial class TaskComment
  {
      public int TaskCommentID { get; set; }
      public Nullable&lt;int&gt; TaskID { get; set; }
      public Nullable&lt;int&gt; AuthorID { get; set; }
      public string Comment { get; set; }
      public Nullable&lt;System.DateTime&gt; TimeStamp { get; set; }
  
      public virtual Task Task { get; set; }
      public virtual Employee Employee { get; set; }
  }
  </code></pre>
  
  <p>Here's my "MainView"</p>
  
  <pre><code>@Html.Action("_GetForTask", "TaskComment", new { TaskID = Model.TaskID })
  </code></pre>
  
  <p>_GetForTask PartialView</p>
  
  <pre><code>@model IEnumerable&lt;ProjectYesha.Models.TaskComment&gt;
  &lt;div id="comments"&gt;
      &lt;ul&gt;
          @foreach (var taskComment in Model)
          {
              &lt;li&gt;@taskComment.Comment&lt;/li&gt;
          }
      &lt;/ul&gt;  
      @using (Html.BeginForm("_Submit", "TaskComment", FormMethod.Post))
      { 
          @Html.AntiForgeryToken()
          @Html.Action("_TaskCommentForm", "TaskComment", new { TaskID = ViewBag.TaskID })
      }
  
  &lt;/div&gt; 
  </code></pre>
  
  <p>_TaskCommentForm PartialView</p>
  
  <pre><code>@model ProjectYesha.Models.TaskComment
  
  @Html.HiddenFor(m=&gt; m.TaskCommentID)
  @Html.HiddenFor(m=&gt; m.TaskID)
  @Html.HiddenFor(m=&gt; m.AuthorID)
  @Html.HiddenFor(m=&gt; m.TimeStamp)
  
  @Html.HiddenFor(m=&gt; m.Employee)
  @Html.HiddenFor(m=&gt; m.Task)
  &lt;div&gt;   
      @using (Html.BeginForm())
      { 
          @Html.EditorFor(m =&gt; m.TaskID)
          @Html.EditorFor(m =&gt; m.Comment)
          &lt;input type="submit" value = "Submit" /&gt;
      }
  &lt;/div&gt;
  </code></pre>
  
  <p>TaskCommentController</p>
  
  <pre><code> public PartialViewResult _GetForTask(Int32 taskID)
          {
              ViewBag.TaskID = taskID;
              List&lt;TaskComment&gt; comments = db.TaskComments.Where(c =&gt; c.TaskID == taskID).ToList();
              return PartialView("_GetForTask", comments);
          }
  
          [ChildActionOnly()]
          public PartialViewResult _TaskCommentForm(Int32 taskID)
          {
  
              TaskComment comment = new TaskComment() 
              {
                  TaskID = taskID ,
              };
              return PartialView("_TaskCommentForm", comment);
          }
  
          [HttpPost]
          [ValidateAntiForgeryToken()]
          public PartialViewResult _Submit(TaskComment comment)
          {
              db.TaskComments.Add(comment);
              db.SaveChanges();
  
              List&lt;TaskComment&gt; comments = db.TaskComments.Where(c =&gt; c.TaskID == comment.TaskID).ToList();
              ViewBag.TaskID = comment.TaskID;
  
              return PartialView("_GetForTask", comments);
          }
  </code></pre>