开发者

Ternary Operator in Razor View [duplicate]

This question already has answers here: 开发者_如何学C Closed 11 years ago.

Possible Duplicate:

How to use ternary operator in razor (specifically on HTML attributes)?

I am trying to do the following but its erroring so I'm obviously doing something wrong with the Razor syntax:

<td>@{item.Licence.MachineId != null ? @:"TB Master" : @:"HandHeld"}  </td>


The following should work:

<td>@(item.Licence.MachineId != null ? "TB Master" : "HandHeld")</td>


Try this

<td>@(item.Licence.MachineId != null ? "TB Master" : "HandHeld")</td>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜