I have a list collection of umbraco pages and i want to loop through checking if a bool property is true and if so i want to apply a specific class to the div
How can i write an else if ternary operator in razor to apply a class to to a div. If i wasnt using ternary then it would look like this
if package.GetPropertyValue<bool>("test")
{
<div class="test1"></div>
}
else if (package.GetPropertyValue<bool>("test1"))
{
<div class="test1"></div>
}
else if (package.GetPropertyValue<bool>("test2"))
{
<div class="test2"></div>
}
in my razor view it would be something like as follows (but not right)
@(package.GetPropertyValue<bool>("test") ? "test" : package.GetPropertyValue<bool>("test1") ? "test1" : "test2" )
many thanks paul
Aucun commentaire:
Enregistrer un commentaire