I want to do a check if something is an integer, so if it is 8, then assign a certain value to a variable, if not, another variable, pretty straightforward, but I get an error on this?
var getColor = umbraco.presentation.nodeFactory.Node.GetCurrent().GetProperty("textColor" + i).Value;
if (getColor == 8)
{
var color = "black";
}
else
{
var color = "white";
}
Then I want to print out the variable in my HTML as a class like so:
<div class="headline <% color %>"></div>
The whole code looks like:
<div class="slides" onmouseleave="startSlider();">
<%for(int i = 1; i < 5; i++) { %>
<%
var getColor = umbraco.presentation.nodeFactory.Node.GetCurrent().GetProperty("textColor" + i).Value;
if (getColor == "8")
{
var color = "black";
}
else
{
var color = "white";
}
%>
<%if(umbraco.presentation.nodeFactory.Node.GetCurrent().GetProperty("image"+ i).Value != "") {%>
<div class="slide" id="slide<%=i%>" onclick="location.href = '<%=umbraco.library.NiceUrl(int.Parse(umbraco.presentation.nodeFactory.Node.GetCurrent().GetProperty("link"+ i).Value))%>';" style="display:<%if(i != 1){%>none<%}%>;" tmpcolor="<%=umbraco.presentation.nodeFactory.Node.GetCurrent().GetProperty("backgroundColor"+ i).Value%>">
<div class="image" id="image<%=i%>" style="background: url(<%=umbraco.presentation.nodeFactory.Node.GetCurrent().GetProperty("image"+ i).Value%>) center center;"></div>
<div class="headline <%=color%>"><%=umbraco.presentation.nodeFactory.Node.GetCurrent().GetProperty("headline"+ i).Value%></div>
<div class="subline"><%=umbraco.presentation.nodeFactory.Node.GetCurrent().GetProperty("subline"+ i).Value%></div>
<div class="menuitems">
<%for(int y = 1; y < 5; y++) { %>
<%if(umbraco.presentation.nodeFactory.Node.GetCurrent().GetProperty("menutext"+ y).Value != "") {%><span class="item<%if(i==y){%> selected<%}%>" onmouseover="gotoSlide(<%=y%>);"><a title="<%=umbraco.presentation.nodeFactory.Node.GetCurrent().GetProperty("headline"+ i).Value%>" href='<%=umbraco.library.NiceUrl(int.Parse(umbraco.presentation.nodeFactory.Node.GetCurrent().GetProperty("link"+ y).Value))%>'><%=umbraco.presentation.nodeFactory.Node.GetCurrent().GetProperty("menutext"+ y).Value%></a><br/></span><%}%>
<%}%>
</div>
</div>
<%}%>
<%}%>
</div>
Im getting the error that "color in not in the current context"