title: .NET MVC Ajax Form - How do you hide it?
body: <p>Ok, everything is 'functionally' working with what I am attempting to accomplish and once again, I am sure this is something dumb, but I cannot figure out how to do this one thing.</p>
  
  <p>I have an edit form for an entity, lets say a car.  This 'car' can have 0 - many passengers.  So on my edit form, I have all the fields for the car, then a list view showing each passenger (partial).  I also have a 'add new passenger' button that will render a new partial view that allows you to enter a passenger.  This has a cancel link and an add button to submit an Ajax form.  When you add a passenger, the passenger is automatically added to the list, but I need the enter passenger form to go away.  I have tried using the onSuccess and onComplete functions to hide the div that the form is in, but both render just the partial view HTML elements (white screen, text) and not the partialView in the context of the entire page.</p>
  
  <p>Sources:
  1)  Main Edit View</p>
  
  <pre><code>    &lt;script type="text/javascript"&gt;
      Function hideForm(){
          document.getElementById('newPassenger').style.display = 'none';
      }
  
  &lt;/script&gt;
  &lt;h2&gt;Edit&lt;/h2&gt;
  
  &lt;%-- The following line works around an ASP.NET compiler warning --%&gt;
  &lt;%= ""%&gt;
  
  &lt;%Html.RenderPartial("EditCar", Model)%&gt;
  &lt;h2&gt;Passengers for this car&lt;/h2&gt;
  &lt;%=Ajax.ActionLink("Add New Passenger", "AddPassenger", New With {.ID = Model.carID}, New AjaxOptions With {.UpdateTargetId = "newPassenger", .InsertionMode = InsertionMode.Replace})%&gt;
  &lt;div id="newPassenger"&gt;&lt;/div&gt;
  &lt;div id="passengerList"&gt;
      &lt;%Html.RenderPartial("passengerList", Model.Passengers)%&gt;
  &lt;/div&gt;
  &lt;div&gt;
      &lt;%= Html.ActionLink("Back to List", "Index") %&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>2) AddPassenger View.  The cancel link below is an action that returns nothing, thus removing the information in the div.</p>
  
  <pre><code>&lt;%  Using Ajax.BeginForm("AddPassengerToCar", New With {.id = ViewData("carID")}, New AjaxOptions With {.OnSuccess = "hideForm()", .UpdateTargetId = "passengerList", .InsertionMode = InsertionMode.Replace})%&gt;   
      &lt;%=Html.DropDownList("Passengers")%&gt; 
      &lt;input type="submit" value="Add" /&gt;
      &lt;%=Ajax.ActionLink("Cancel", "CancelAddControl", _
                                              New AjaxOptions With {.UpdateTargetId = "newPassenger", .InsertionMode = InsertionMode.Replace})%&gt;&lt;% end using %&gt;
  </code></pre>