title: ASP.Net [HiddenInput] Data Attribute not working when rendered with Html.EditorForModel in Razor?
body: <p>I have the following model:</p>
  
  <pre><code>public class Product
  {
      [HiddenInput(DisplayValue = false)]
      public int ProductID { get; set; }
  
      [Required(ErrorMessage="Please enter a product name")]
      public string Name { get; set; }
  
      [Required(ErrorMessage="Please enter a description")]
      [DataType(DataType.MultilineText)]
      public string Description { get; set; }
  
      [Required]
      [Range(0.01, double.MaxValue, ErrorMessage="Please enter a positive price")]
      public decimal Price { get; set; }
  
      [Required(ErrorMessage="Please specify a category")]
      public string Category { get; set; }
  
      public byte[] ImageData { get; set; }
  
      [HiddenInput(DisplayValue = false)]
      public string ImageMimeType { get; set; }
  }
  </code></pre>
  
  <p>I am referencing <code>System.Web.Mvc</code> and <code>System.ComponentModel.DataAnnotations</code>.</p>
  
  <p>I am then rendering this out in my view as follows:</p>
  
  <pre><code>&lt;h1&gt;Edit @Model.Name&lt;/h1&gt;
  
  @using (Html.BeginForm("Edit", "Admin", FormMethod.Post, new { enctype = "multipart/form-data" })) {
  @Html.EditorForModel()
  
  &lt;div class="editor-lable"&gt;Image&lt;/div&gt;
  &lt;div class="editor-=field"&gt;
      @if (Model.ImageData == null)
      {
          @:None
          }
      else
      {
          &lt;img width="150" height="150" src="@Url.Action("GetImage", "Product", new { Model.ProductID })" /&gt;
      }
      &lt;div&gt;Upload new image: &lt;input type="file" name="Image" . /&gt;&lt;/div&gt;
  &lt;/div&gt;
  &lt;input type="submit" value="Save" /&gt;
  @Html.ActionLink("Cancel and return to List", "Index")
  </code></pre>
  
  <p>}</p>
  
  <p>The problem is that while the <code>[Required]</code> annotations are working properly the <code>[HiddenInput]</code> fields are not actually hiding.  The html source doesn't even have the hidden attribute showing up.</p>
  
  <p>Why isn't <code>Html.EditorForModel</code> applying the <code>[HiddenInput]</code> attribute to those properties?  Any ideas?</p>