I can't understand why the following code doesn't work
@{
bool isDisabled = true; // I have omitted the if-statement that makes this true
<select class="form-control"
asp-items="Model.Locations"
asp-for="@Model.Id"
@if (isDisabled)
{
@Html.Raw("disabled")
}
>
</select>
}
The HTML renders without the word "disabled" inside the end of the tag. It's as though Html.Raw can't be used here. It works if I take it outside of the tag i.e. I can get it to render as <Select ... >disabled</select>
- just not <select ... disabled ></select>
I basically want to set the bool to true on a certain condition which means that the field should be un-editable. I thought this would be the most straightforward way!