I have the following razor code with ternary operator to include or omit a data-* attribute:
<select class="form-control"
@(field.DependentDropdown ? $"data-selected={Model.KeyValues.GetValue(field.Name)}" : "")>
When it renders in HTML it comes out like this:
<select class="form-control"
data-selected="Toyota" yaris="">
As you can see the value for the data-selected attribute is not being correctly formatted - it should be one word enclosed in double quotes "Toyota Yaris".
How do I correctly escape or add doubles quotes to:
$"data-selected={Model.KeyValues.GetValue(field.Name)}"