Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我目前有这个代码
@if(true) { <text> <td class="add"></td> </text> } else { <text> <td class="remove"></td> </text> }
我想切换到这样的东西
<td> @if(true) { <text> @class="add" </text> } else { <text> @class="remove" </text> }</td>
我不确定这是否正确,或者它的正确语法
@functions { object getAttributes(bool val) { if (val) { return new {@class="add"}; } return new { @class="remove"}; } } <td> @Html.TextBoxFor(model => model.FirstName,@getAttributes(style)) @getAttributes(style) <td>