I have the following html in a cshtml file in our episerver project:
<div class="col-sm-7 col-md-8">
If there is no background image selected then I want to change those values to be full width.
This is what I have been trying to do, but it is causing a exception fault:
<div class="@(!ContentReference.IsNullOrEmpty(Model.CurrentBlock.Image) ? col-sm-7 col-md-8 : col-sm-12 col-md-12)">
I am hoping it boils down to a syntax issue I am not familiar with as a newbie?
Your expression isn't returning strings
.
It should be:
<div class="@(!ContentReference.IsNullOrEmpty(Model.CurrentBlock.Image) ? "col-sm-7 col-md-8" : "col-sm-12 col-md-12")">