开发者

Ternary Operator in Razor View [duplicate]

开发者 https://www.devze.com 2023-03-11 02:47 出处:网络
This question already has answers here: 开发者_如何学C Closed 11 years ago. Possible Duplicate: How to use ternary operator in razor (specifically on HTML attributes)?
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

精彩评论

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