In my ASP.NET Core 5 razor pages application, I have the following piece of code which is working:
@Html.DisplayFor(modelItem => item.IsComplete)
It shows a disabled checkbox as IsComplete
is a boolean.
I would like to have text in place of the check box and so I tried the two below unsuccessfully.
@Html.Raw(modelItem => item.IsComplete == true ? "Completed":"")
and
@(modelItem => item.IsComplete == true ? "Completed":"")
The error I get is
error CS1660: Cannot convert lambda expression to type 'object' because it is not a delegate type
How can I show text conditionally?
Wrap the text you want within an @if()
condition, like so:
@if(Model.isCompleted) {
<p> Completed Transcation </p>
}