我正在使用新的 Razore 视图引擎更新旧的 .aspx 视图。我有很多地方有这样的代码:
<span class="vote-up<%= puzzle.UserVote == VoteType.Up ? "-selected" : "" %>">Vote Up</span>
理想情况下,我想这样做:
<span class="vote-up@{puzzle.UserVote == VoteType.Up ? "-selected" : ""}">Vote Up</span>
但是这里有两个问题:
vote-up@{puzzle.UserVote
@puzzle.UserVote == VoteType.Up
@puzzle.UserVote
有谁知道如何解决这些问题?
这应该有效:
<span class="vote-up@(puzzle.UserVote == VoteType.Up ? "-selected" : "")">Vote Up</span>