Hi
I am trying to figure out how to write between inline expressions to display colors based on the condition
<div class=" noPad" style="display: grid; grid-template-columns: 9fr 1fr;">
<div class="glance-text">
<div class="glance-lastDate">
<%: Html.TranslateTag("Last Message","") %> <%: item.Sensor.LastDataMessage == null ? Html.TranslateTag("Unavailable","Unavailable") : (item.Sensor.LastCommunicationDate.ToElapsedMinutes() > 120 ? item.Sensor.LastCommunicationDate.OVToLocalDateTimeShort() : item.Sensor.LastCommunicationDate.ToElapsedMinutes().ToString() + " " + Html.TranslateTag("Minutes ago","Minutes ago") ) %>
</div>
</div>
</div>
I would like to add colors in these syntaxes in the ascx file html when:
<%: Html.TranslateTag("Last Message","") %> <%: item.Sensor.LastDataMessage == null ? Html.TranslateTag("Unavailable","Unavailable") :
Unavailable to be the red color with background color black
(item.Sensor.LastCommunicationDate.ToElapsedMinutes() > 120 ? item.Sensor.LastCommunicationDate.OVToLocalDateTimeShort() :
date 15/07/2022 4:56 pm to be a blue color with background color white
item.Sensor.LastCommunicationDate.ToElapsedMinutes().ToString() + " " + Html.TranslateTag("Minutes ago","Minutes ago") ) %>
2 Minutes ago to be an orange color with background color dark blue
C#
public DataMessage LastDataMessage
{
get
{
try
{
if (LastDataMessageGUID != null && LastDataMessageGUID != Guid.Empty && LastCommunicationDate > DateTime.UtcNow.AddMonths(-12))
{
if (_LastDataMessage == null || _LastDataMessageGUID != _LastDataMessage.DataMessageGUID)
{
_LastDataMessage = DataMessage.LoadLastBySensorQuick(SensorID, LastDataMessageGUID, LastCommunicationDate);
}
}
return _LastDataMessage;
}
catch (Exception ex)
{
try
{
ExceptionLog.Log(ex);
}
catch
{
}
return null;
}
}
set
{
DataMessage.ClearLastBySensorQuick(SensorID);
_LastDataMessage = value;
if (value != null)
this.LastDataMessageGUID = value.DataMessageGUID;
}
}
Sincerely thanks.