title: Custom Attribute in c# to give Custom data-attribute in html
body: <p>I'd like to be able to make a data attribute in c# for an object in my model. When this is displayed. I'd like the html to render the value in a data attribute within the html itself.</p>
  
  <p>In my head, the code looks similar to this.</p>
  
  <pre><code>public class AffectsAttribute:Attribute
  {
      public string[] Departments { get; set; }
  
  }
  
  
  [EmailAddress]
  [Required(ErrorMessage = "Email is required")]
  [Affects(Departments = new string[]{"Coaches"})]
  public string Email {get; set;}
  </code></pre>
  
  <p>Then in the html, after being called with razor it would look something like this</p>
  
  <pre><code>@Html.EditorFor(model =&gt; model.Email)
  
  
  &lt;input class="text-box single-line" data-affects="Coaches" data-val="true" data-val-email="The Email field is not a valid e-mail address." data-val-required="Email is required" id="Email" name="Email" type="email"  value=""&gt;
  </code></pre>
  
  <p>I have no clue how to specify that I would like the additional data attribute to be added when the item is rendered on a page. Can anyone help?</p>