title: How to add data attributes to html element in ASP.NET MVC?
body: <p>I learned <a href="https://stackoverflow.com/questions/1305734/is-it-ok-to-add-your-own-attributes-to-html-elements">few minutes ago</a> that adding data attributes is a nice way to add custom information to html elements. So I tried to do like this:</p>
  
  <pre><code>&lt;%= Html.TextBox ("textBox", "Value", new { data-myid = m.ID })%&gt;
  </code></pre>
  
  <p>But it ends up as a syntax error. How can I define custom data attributes?</p>
  
  <p>EDIT:</p>
  
  <p>I see that I can achieve this effect using:</p>
  
  <pre><code>&lt;%= Html.TextBox ("textBox", "Value", new Dictionary&lt;string, object&gt; {{ "data-myid", m.ID }})%&gt;
  </code></pre>
  
  <p>But that doesn't look...umm...clean! Is there any better way to do this?</p>