So I have seen this done before and I completely forgot where or what the syntax is.
Help is greatly appreciated.
So I have an element I want to add an CSS style to depending on what property is filled out or not in the Umbraco CMS. I thought it involved colons (:) or something like that after the element’s tag. But not entirely sure.
I want to do something like this
foreach(var item in @Model.myNodeList)
if(@item.myProperty != String.Empty){
<div class="myStyleOne">
}
else if(@item.myProperty == String.Empty){
<div class="myStyleTwo">
}
else{
<div class="myDefaultStyle">
}
<p>My content that will be inside of this div with different starting tags</p>
</div>
}
I know this code is not entirely correct and I am missing something. Can anyone point me in the right direction? Thanks.
OK, just in case anyone else wanted to do this too. I found out what it is.
This is the solution. It involves adding an @: sign in front of your elements’ beginning and ending tags.
Note: took out the last else. Thanks @Brandon for that. That didn’t make sense the first time. Brandon’s way or this way works too.