title: Remove time from ASP MVC @Html.TextBoxFor Control using jQuery datepicker
body: <p>How do I prevent the time from showing up when using the jQuery <code>.datepicker()</code>? Below is the section of the model for the two attributes (date taken and expiration date)</p>
  
  <pre><code>    [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:d}")]
      [DisplayName("Expiration Date")]
      public string ExpirationDate { get; set; }
  
      [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:d}")]
      [DisplayName("Date Taken")]
      public string DateTaken { get; set; }
  </code></pre>
  
  <p>This works fine using the <code>@Html.EditorFor</code> control on the view I'm working on. However, when I change that control from this: </p>
  
  <pre><code> @Html.EditorFor(model =&gt; model.DateTaken)
  </code></pre>
  
  <p>to this: </p>
  
  <pre><code>@Html.TextBoxFor(m =&gt; m.DateTaken, new { id = "dtkn" })
  </code></pre>
  
  <p>in order to get this to work (label which control has the <code>datepicker</code> applied to it): </p>
  
  <pre><code>&lt;script&gt;
      $(function () {
          $("#dtkn").datepicker('setDate');
          $("#exp").datepicker('setDate');
      });
  
      $.datepicker.setDefaults({
          buttonImageOnly: true,
          buttonImage: '&lt;%=Url.Content("~/Content/images/magnify.gif") %&gt;',
          defaultDate: -1,
          gotoCurrent: true,
          prevText: "&lt;&lt; Prev",
          nextText: "Next &gt;&gt;"
      });
  &lt;/script&gt;
  </code></pre>
  
  <p>suddenly the time begins to show up. Any suggestions? </p>
  
  <p>EDIT </p>
  
  <p>I have tried the following formats and none will work: </p>
  
  <pre><code>$("#dtkn").datepicker({ dateFormat: 'dd-mm-yy' }).val();
  $("#dtkn").datepicker({ dateFormat: 'yy-mm-dd' });
  $("#dtkn").datepicker('getDate').format('yyyyMMdd');
  </code></pre>
  
  <p>and this: </p>
  
  <pre><code>$("#dtkn").datepicker('getDate').datepicker('dd/mm/yy');
  $('#dtkn').datepicker('option', { dateFormat: 'd MM y' });
  </code></pre>
  
  <p>Here is the error I'm seeing the Chrome debugging console: </p>
  
  <pre><code>Uncaught TypeError: Cannot call method 'datepicker' of null 
  </code></pre>