Search code examples
c#.nettext

Cant show text with if in .NET core


I have a Boolean in item.estado and i want to show "Pendiente" if it's true and "Terminado" if it's false, but this doesn't work.

                    <div class="d-flex w-100 justify-content-between">
                        <h4 class="mb-1">@Html.DisplayFor(modelItem => item.id_consulta)</h4>
                        <small class="text-muted">@{if(item.estado){Html.DisplayText("Pendiente");} else {Html.DisplayText("Terminado");}}</small>
                    </div>
                    <p class="mb-2">Nombre solicitud: @Html.DisplayFor(modelIte)</p>
                </a>```

Solution

  • I ended using <text><\text> instead of html.DisplayText()

    <small class="text-muted">@{if(item.estado){<text>Pendiente</text>;} else {<text>Terminado</text>;}}</small>