8

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>
Community
  • 1
  • 1
jon
  • 93
  • 1
  • 1
  • 3

2 Answers2

19

The following should work:

<td>@(item.Licence.MachineId != null ? "TB Master" : "HandHeld")</td>
Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
1

Try this

<td>@(item.Licence.MachineId != null ? "TB Master" : "HandHeld")</td>
Khepri
  • 9,547
  • 5
  • 45
  • 61