title: How to update parent view after submitting a form through a partial view?
body: <p>I have a view which when a teacher is logged in lists the complete details of a student , it also lists the tasks given to the student by the teacher logged in. If the teacher wants to create a new task for the student he clicks the create new link which in turns make an Ajax call to the controller:</p>
  
  <pre><code>@Ajax.ActionLink("Create", "CreateTask", "Task", new { id = Model.StudentId },
  new AjaxOptions
              {
                  HttpMethod = "GET",
                  InsertionMode = InsertionMode.Replace,
                  UpdateTargetId = "create-div"
              }, new { @class = "btn btn-default" })
  </code></pre>
  
  <p>which returns a partial view</p>
  
  <pre><code>[HttpGet]
  public ActionResult CreateTask(int ?id)
      {
  
          //........
          return PartialView("PartialViews/Task/_CreateTaskPartial");
      }
  </code></pre>
  
  <p>In the partial view I am using Ajax.BeginForm to submit the data to create the actual task as follows</p>
  
  <pre><code> @using (Ajax.BeginForm("CreateTask", "Task",new AjaxOptions { UpdateTargetId = "create-div", InsertionMode = InsertionMode.Replace }))
  {
      // Form data
  }
  </code></pre>
  
  <p>and finally in the CreateTask controller I create the task</p>
  
  <pre><code>[HttpPost]
      [ValidateAntiForgeryToken]
      public ActionResult Create([Bind(Include="TaskId")] Task @task)
      {
  
          if (ModelState.IsValid)
          {
              db.Tasks.Add(@task);
              db.SaveChanges();
  
              // If everything is successfull return empty     
  
              return new EmptyResult();                
          }
  
          // If model errors send the view back
          return PartialView("PartialViews/Task/_CreateTaskPartial", @task);
      }
  </code></pre>
  
  <p>It creates the new task successfully but it does not update the main view which lists the details of a student and a list of created tasks. I have to refresh the page to see the last task added.</p>
  
  <p>How can I make it possible so that when a 6th task is added via partial view, on success it updates the parent view and lists the 6th task also ?</p>
  
  <p>I am not very experienced in MVC so please correct me where am I doing wrong.</p>