This is my first time using .NET so please excuse my ignorance.
I'm trying to change the value of the class atribute in a HTML element, depending on some if/else statements, like so:
@if (item.HasAir)
{
var icon = "fa fa-plane";
var circleColour = "icon-bg-blue";
}
else if (item.HasCar)
{
var icon = "fa fa-car";
var circleColour = "icon-bg-cyan";
}
<span class="icon-cirle @circleColour" aria-hidden="true">
<span class="@icon"></span>
</span>
However when refreshing the page in my browser, I'm getting a Compilation Error:
The name 'circleColour' does not exist in the current context
Looking at the code above, can anyone explain what I'm doing wrong?
Other info:
- .NET Framework version: 4.0.x
- ASP.NET version: 4.7.x