MVC Razor View Engine, add logic between quotemarks
I'm really new at using Razor with MVC, and so far I really like it.
One little thing I want to do is write a variables value to an attribute in HTML. For example, if I had the following:
开发者_StackOverflow中文版 <table style="width: 100%">
<tr>
<th>
ID
</th>
<th>
Name
</th>
<th>
Value
</th>
</tr>
@foreach (var item in Model)
{
<tr id="ID@item.id">
<td>
@item.id
</td>
<td>
@item.name
</td>
<td>
@item.value
</td>
<td>
</tr>
}
</table>
I would want all the tags to have an ID equal to "ID[insert item's id]", but instead I get an ID equal to "ID@item.id".
How do I write a variable's name between HTML quote marks?
Thanks!
This pattern is recognized as an email address. Do the following to work around this behavior:
<tr id="ID@(item.id)">
精彩评论