Show fixed text when value is empty
When a field is empty, it is possible to show a fixed text to tell the user that there is no data for this field.
<tr>
<td>@Model.E222.Label</td>
@if (!@Model.E222.IsEmpty){
<td>
<span>@Model.E222</span>
</td>
}
else{
<td>
<span>empty</span>
</td>
}
</tr>
Extra explanation on the code:
-
In the first part (in de 'if') is written what to do when value is not empty: shown value.
-
In the second part (in the 'else') is written what to do when value is empty: show text "empty".
The result looks like:
The code placed in a table:
<table class="table">
<thead>
</thead>
<tbody>
<tr>
<td>@Model.E222.Label</td>
@if (!@Model.E222.IsEmpty){
<td>
<span>@Model.E222</span>
</td>
}
else{
<td>
<span>empty</span>
</td>
}
</tr>
</tbody>
</table>