title: Adding class to EditorFor in MVC
body: <p>I want to show <code>Enum</code> in EditorFor. I use Editor Template for show it.(DropDownList).</p>
  
  <p>I have malty <code>EditorFor</code> in view. I want to set class for some controls.</p>
  
  <pre><code>@Html.EditorFor(m =&gt; m.Position, new { @class = "smallinput", style = "width:150px !important" })
  @Html.EditorFor(m =&gt; m.DocumentType)
  </code></pre>
  
  <p>In Editor: Views/Shared/DisplayTemplates/Enum.cshtml</p>
  
  <pre><code>@model Enum
  @{
     var values = Enum.GetValues(ViewData.ModelMetadata.ModelType).Cast&lt;object&gt;()
                   .Select(v =&gt; new SelectListItem
                   {
                       Selected = v.Equals(Model),
                       Text = v.GetDisplayName(),
                       Value = v.ToString()
                   });
  }
  @Html.DropDownList("", values)
  </code></pre>
  
  <p>In Model</p>
  
  <pre><code>[DisplayName("نوع سند")]
  [UIHint("Enum")]
  public DocumentType DocumentType { get; set; }
  </code></pre>