title: ASP.NET MVC Razor Concatenation
body: <p>I'm trying the render an HTML list that looks like the following, using the Razor view engine:</p>
  
  <pre><code>&lt;ul&gt;
    &lt;li id="item_1"&gt;Item 1&lt;/li&gt;
    &lt;li id="item_2"&gt;Item 2&lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>The code that I am attempting to use to render this list is:</p>
  
  <pre><code>&lt;ul&gt;
  @foreach (var item in Model.TheItems)
  {            
    &lt;li id="item_@item.TheItemId"&gt;Item @item.TheItemId&lt;/li&gt;
  }
  &lt;/ul&gt;
  </code></pre>
  
  <p>The parser is choking, because it thinks that that everything to the right of the underscore in the id attribute is plain text and should not be parsed.  I'm uncertain of how to instruct the parser to render TheItemId.</p>
  
  <p>I don't want to but a property on the model object that includes the item_ prefix.</p>
  
  <p>I also have to keep this syntax as I am using the list with JQuery Sortable and with the serialize function that requires the id attribute to be formatted in this syntax.</p>