My goal is to conditionally disable a drop-down depending on the status of the model object passed to the view.
The following code correctly renders a disabled <select> tag (but not conditionally):
<select class="form-control" asp-for="Priority" asp-items="@priorityList" disabled></select>
The following does not. The attribute disabled does not appear in the page source for the rendered page:
@{ string disabled = Model.CaseMode == Mode.Active ? "" : "disabled"; }
<select class="form-control" asp-for="Priority" asp-items="@priorityList" @disabled></select>
Also, the following also does not disable the <select> tag.
<select class="form-control" asp-for="Priority" asp-items="@priorityList" @((Model.CaseMode == Mode.Closed) ? "disabled" : "")></select>
I assume the issue has to do with the tag helper processing the <select> tag before the string substitution is done in the template. Can anyone suggest how I can conditionally disable this element without have to render two separate elements in an if else structure?