title: Repeated UI functionality in MVC
body: <p>I have a few screens which have duplicated complex UI functionality. i.e. Drop down A triggers a JSON call to my Controller, which populates the values in drop down B and C, based on the value selected in drop down A.</p>
  
  <p>So, on the screens, I have drop down A, and then under that, B and C.</p>
  
  <p>This is duplicated UI code on 3 screens (Growing to 5 soon). But they make use of the same Controller call to do the population.</p>
  
  <p>Is there a way I can create a partial view, which I can place in a form (Form is submitted via a normal Form post), and the values of the selections can then be passed back with the values of all the other form items that are submitted? The partial view would have the markup, as well as the Javascript I use to call the controller?</p>
  
  <p>I'm not sure if I can then include the values within the partial view, in the Form post, and have them available to the controller.</p>
  
  <p>I have started investigating EditorTemplates, but all I have is the Model for the template:</p>
  
  <pre><code>public class AccountCombinationTemplateModel
  {
      public int SourceEntityId { get; set; }
      public int DestinationEntityId { get; set; }
      public int EntityEventTypeId { get; set; }
  
      public List&lt;SelectListItem&gt; Accounts { get; set; }
      public List&lt;SelectListItem&gt; ThirdParties { get; set; }
  
  }
  </code></pre>
  
  <p>and an empty AccountCombinationTemplate.cshtml file. Not sure if I need a controller etc.</p>
  
  <p>My parent model (The main model I use for the view) now references the new model created above:</p>
  
  <pre><code>public AccountCombinationTemplateModel AccountModel { get; set; }
  </code></pre>
  
  <p>So all the properties that were in the parent model, have been moved into the AccountCombinationTemplateModel.</p>
  
  <p>On my View, I now have:</p>
  
  <pre><code>@Html.EditorForModel(Model.Details.AccountModel)
  </code></pre>
  
  <p>That is on the view, where I want my Drop downs to appear.</p>
  
  <p>I created a new empty view called AccountCombinationTemplate.cshtml in my View\Shared\EditorTemplates folder.</p>
  
  <p>That view looks like this:</p>
  
  <pre><code>@model BasicFinanceUI.Models.AccountCombinationTemplateModel
  &lt;div class="row"&gt;
      &lt;div class="form-group col-xs-12 col-lg-3 divAccounts"&gt;
          @Html.LabelFor(x =&gt; x.EntityEventTypeId)
          @Html.DropDownListFor(x =&gt; x.EntityEventTypeId, Model.EntityEventTypes, new { @class = "EntityEventTypeId form-control", @onchange = "changeDisplay(this)" })
      &lt;/div&gt;
      &lt;div class="form-group col-xs-12 col-lg-5 divAccounts"&gt;
          @Html.LabelFor(x =&gt; x.SourceEntityId)
          @Html.DropDownListFor(x =&gt; x.SourceEntityId, Model.Sources, new { @class = "SourceEntityId form-control" })
      &lt;/div&gt;
      &lt;div class="form-group col-xs-12 col-lg-5 divAccounts"&gt;
          @Html.LabelFor(x =&gt; x.DestinationEntityId)
          @Html.DropDownListFor(x =&gt; x.DestinationEntityId, Model.Destinations, new { @class = "DestinationEntityId form-control" })
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I my existing controller, I have added the new EditorModel above as a property of the main model for the view, and populated it and it's properties.</p>
  
  <p>But when I run the screen, where I have the @Html.Edit..., nothing is rendered. No errors either. It;s as if it can't find the View?</p>