title: ASP.NET MVC Editor-Templates/UIHint with parameters
body: <p>I've been using Editor-Templates in the past like this, by applying the following data annotation:</p>
  <pre><code>[UIHint(&quot;SomeTemplate&quot;)]
   
  </code></pre>
  <p><strong>ViewModel:</strong></p>
  <pre><code> public class MicroViewModel
   {
      public IEnumerable&lt;LabMicro&gt; Micros { get; set; }
  
      [UIHint(&quot;DateTime&quot;)]
      public DateTime Date { get; set; }
  
      public int CaseNo { get; set; }
  
      [UIHint(&quot;SampleTypes&quot;)]
      public int LabSampleTypeID { get; set; }
  
      [UIHint(&quot;SampleDetails&quot;)]
      public int LabSampleDetailID { get; set; }
   }
  </code></pre>
  <p>If I wanted to use a specific date picker control as opposed to the regular one, it can be implemented as follows.</p>
  <p><strong>Example:</strong></p>
  <pre><code>@model DateTime?    
  @Html.TextBox(&quot;&quot;,  String.Format(&quot;{0:yyyy-MM-dd}&quot;, Model.HasValue ? 
          Model : DateTime.Today), new { @class = &quot;dp&quot;, style=&quot;width:100px&quot; })
  
  &lt;script type=&quot;text/javascript&quot;&gt;    
      $(document).ready(function () {    
          $(&quot;.dp&quot;).datepicker({    
              changeMonth: true,    
              changeYear: true,
              dateFormat: 'yy-mm-dd'    
          });    
      });      
  &lt;/script&gt;  
  </code></pre>
  <p>For my ID fields, I'd like to make use of the jQuery auto-complete component.</p>
  <p><strong>Question:</strong></p>
  <p>How would I go about passing additional parameters to the <code>UIHint</code> partial view for <code>LabSampleTypeID</code> and <code>LabSampleDetailID</code>? <em>(As Id like to have an auto-complete Editor-Template that'll take a URL and property names for example)</em></p>
  <p><strong>What I think my auto-complete Editor-Template/Partial should look like:</strong></p>
  <pre><code>$(&quot;.auto&quot;).autocomplete({
      source: function(request, response) {
          $.ajax({
              url: '[#URL_TO_USE]',
              dataType: &quot;json&quot;,
              data: {
                  filter: request.term
              },
              success: function(data) {
                  response($.map(eval(data), function(item) {
                      return {
                          label: item.[#PROPERTY_TO_USE]
                      }
                  }));
              }
          })
      }
  });
  </code></pre>