There is no way to bind an input readonly attribute to a bool.
This results in the following code abomination:
@if (Readonly)
{
<input readonly type="@InputType" class="form-control" aria-describedby="emailHelp" placeholder="@Placeholder" value="@Value" onchange="@ItChanged" />
}
else
{
<input type="@InputType" class="form-control" aria-describedby="emailHelp" placeholder="@Placeholder" value="@Value" onchange="@ItChanged" />
}
To generalize this:
the following construct
<input type="text" @(true ? "readonly" : "") />
results in
Error BL9980 Expressions like 'true ? "readonly" : ""' inside of a tag must be part of an attribute. Previous releases of Blazor supported constructs like '@onclick(...)' or '@bind(...)'.These features have been changed to use attribute syntax. Use 'onclick="@..."' or 'bind="..." respectively.
This is working fine
<input type="text" readonly=@true/>
<input type="text" readonly=@false/>
(facepalm) - you're right - thanks Mihail!
Most helpful comment
This is working fine