title: Bootstrap datetimepicker with asp .net scaffolding
body: <p>I have simple model class with DateTime property.</p>
  
  <pre><code>    [Required]
      [DataType(DataType.DateTime)]
      public DateTime When { get; set; }
  </code></pre>
  
  <p>Currently Visual Studio Scaffolding generate this:</p>
  
  <pre><code>    &lt;div class="form-group"&gt;
          @Html.LabelFor(model =&gt; model.When, htmlAttributes: new { @class = "control-label col-md-2" })
          &lt;div class="col-md-10"&gt;
              @Html.EditorFor(model =&gt; model.When, new { htmlAttributes = new { @class = "form-control" } })
              @Html.ValidationMessageFor(model =&gt; model.When, "", new { @class = "text-danger" })
          &lt;/div&gt;
      &lt;/div&gt;
  </code></pre>
  
  <p>It's a simple text box. I want to override default scaffolding. I can add something to default templates and my changes are generated.</p>
  
  <p>How to configure i.e. Create.cs.t4 file to generate bootstrap datetimepicker? </p>
  
  <p>There is an if condition to check when this is a enum</p>
  
  <pre><code>else if (property.IsEnum &amp;&amp; !property.IsEnumFlags) 
  </code></pre>
  
  <p>or bool type</p>
  
  <pre><code>bool isCheckbox = property.TypeName.Equals(boolType);
  </code></pre>
  
  <p>My solution is to add if statement to check whether it's a datetime and generate my own input field. I checked web but it's not a common topic. </p>