title: Generate HTML attributes automatically in MVC 3 depending on data type
body: <p>I have the following property in the MVC Model:</p>
  
  <pre><code>[Range(0, double.MaxValue, ErrorMessage = "The Volume must have positive values!")]       
  public decimal? Volume { get; set; }
  </code></pre>
  
  <p>The generated HTML is </p>
  
  <pre><code>&lt;input type="text" value="1,00" name="Product.Volume" id="Product_Volume" data-val-range-min="0" data-val-range-max="1.79769313486232E+308" data-val-range="The Volume must have positive values!" data-val-number="The field Volume must be a number." data-val="true" class="text-box single-line"&gt;
  </code></pre>
  
  <p>How do I make the generated HTML be something like this:</p>
  
  <pre><code>&lt;input type="text" value="1,00" name="Product.Volume" id="Product_Volume" data-val-range-min="0" data-val-range-max="1.79769313486232E+308" data-val-range="The Volume must have positive values!" data-val-number="The field Volume must be a number." data-val="true" class="text-box single-line" data-type="decimal" &gt;
  </code></pre>
  
  <p>The difference is the additional <strong><code>data-type="decimal"</code></strong></p>
  
  <p>I want the HTML attribute to be added <strong>automatically</strong>, so I do not have to manually add it.</p>