title: Nested partials and templates; How to implement a conditional view or editor?
body: <p>I've been using C# for a while, and have done my share of web-forms, but I'm very new to MVC and I don't really know how to phrase this question to get help from the googles. </p>
  
  <p>I'm developing an MVC site backed by EF and just trying to get the hang of things. So I have a view which allows the User to Create an entity "A". Entity A has a reference to entity B, it's address, which in turn has a reference to entity C, the address' region.</p>
  
  <p>So I've figured out that I can create an Editor Template which can be injected into the Create view for entity A, and returns the A model with it's entity B reference populated. I can do the same thing on the entity B template, injecting an editor template for entity C and getting back the correct entity in B's reference property. </p>
  
  <p>My problem is that entity C is a rarely created entity. The User needs the ability to create one, and it's a very trivial entity (has name and country_enum), so I don't want the user to have to visit a special page just to create this entity after they've figured out that the correct C entity isn't yet in the list, then come back to the page and reenter all the other fields they might have already filled. </p>
  
  <p>How can I create a "conditional" view or set of views, which will allow the user to either select an existing entity C, or create a new entity C if they need to, without leaving the Create - Entity A page?</p>
  
  <p>For clarity this is my current setup:</p>
  
  <p>EntityA-Create.cshtml</p>
  
  <pre><code>@using (Html.BeginForm())
  {
    @Html.AntiForgeryToken()
    @Html.HiddenFor(A =&gt; A.ParentID)
    &lt;fieldset&gt;
      //Entity A editors etc...
      @Html.EditorFor(A =&gt; A.Address, "Address.cshtml", null)
    &lt;/fieldset&gt;      
  }
  </code></pre>
  
  <p>EditorTemplates/Address.cshtml</p>
  
  <pre><code>@model Models.Address
  &lt;div class="editor-label"&gt;
    @Html.LabelFor(B =&gt; B.Property1)
  &lt;/div&gt;
  &lt;div class="editor-field"&gt;
    //Entity B Property editors etc...
  &lt;/div&gt;
  @Html.EditorFor(B=&gt; B.Region, "Region.cshtml", null)
  </code></pre>
  
  <p>In the second view/template, I need a way to render either a full "Create new region" editor template (which it does now), OR a "select existing region from dropdown" view/template/etc, which will still return the Region model the same way it currently does (or close to). My preference would be to avoid JS as much as possible with this solution, but you're the experts!</p>