title: ASP.NET MVC Razor object HtmlAttributes
body: <p>I was wondering what the difference is between the following two ways of adding object HtmlAttributes in ASP.NET MVC 5. I am using a RadioButtonFor html helper in a foreach loop, and I was having trouble setting the name attribute for the radio buttons so that I could group them correctly. I have it working now, but I do not understand why the solution I found (solution found here:<a href="https://stackoverflow.com/questions/13702777/mvc-radiobuttonfor-group">MVC RadioButtonFor group</a> ) works and why mine does not.</p>
  <p><strong>Non-working method:</strong></p>
  <pre><code>&lt;td&gt;@Html.RadioButtonFor(m =&gt; item.PollRating, 1, new { @name = Html.DisplayFor(m =&gt; item.TickerSymbol) }) Below &lt;/td&gt;
  </code></pre>
  <p><em><strong>Working method:</strong></em></p>
  <pre><code> &lt;td&gt;@Html.RadioButtonFor(m =&gt; item.PollRating, 2, new { Name = Html.DisplayFor(m =&gt; item.TickerSymbol) }) Flat &lt;/td&gt;
  </code></pre>
  <p>The difference is using @name vs Name for the object htmlAttributes. Whenever I've had to assign a class or id while using html helpers I used the @class or @id notation, but it does not work in this scenario for name.
  When I hover over @name and Name in Visual Studio I see the same popup message which states:</p>
  <p>&quot;MvcHtmlString 'a.Name {get;}</p>
  <p>Anonymous Types:</p>
  <p>'a is new {MvcHtmlString Name}&quot;</p>
  <p>I am using Visual Studio 2015, target .NET Framework is 4.5.2, and MVC version is 5.2.3.0.</p>