Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ternary Operator in Razor View [duplicate]

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>
like image 541
jon Avatar asked Jun 08 '11 15:06

jon


2 Answers

The following should work:

<td>@(item.Licence.MachineId != null ? "TB Master" : "HandHeld")</td>
like image 124
Darin Dimitrov Avatar answered Nov 15 '22 21:11

Darin Dimitrov


Try this

<td>@(item.Licence.MachineId != null ? "TB Master" : "HandHeld")</td>
like image 42
Khepri Avatar answered Nov 15 '22 22:11

Khepri