Reputation: 271
I have a need for the changing of the headertext image in ASP.NET tab container to different colours. For Example if today is 23/04/2014
and the ImageUrl="~/icons/vwicn114.gif"
of my tab ( with the ID
"FireTraffic" ) and I need to update a record in my SQLserver in 2 days time , I need to change the ImageURL. so think of it as a TrafficLight system. here is a snippet of code to help understand:
connection.Open()
command = New SqlCommand("Select TOP 1 [Due Date] From FireTest Order By [Due Date] Desc", connection)
Dim DueDate As String = command.ExecuteScalar()
Dim Mycommand As New SqlCommand("Select TOP 1 [Date] From FireTest Order By [Date] Desc", connection)
Mycommand = command.ExecuteScalar()
connection.Close()
So my code will be something like :
If mycommand "is 1 day more than" DueDate then firetraffic.ImageURL=Red
If mycommand "is 3 days or less than" DueDate then firetraffic.ImageURL=Yellow
End If
End If
I just don't know what I should be putting into the spaces which obviously aren't code , any guidance to an answer would be greatly appreciated.
Upvotes: 0
Views: 38
Reputation: 89285
Something like this ? :
Dim d1 As DateTime = DateTime.Now
Dim dueDate As DateTime = .....
Dim result = ""
'If overdue for one day or more'
If (d1 - dueDate).Days >= 1 Then
result = "red"
'If 3 days or more to due date'
ElseIf (dueDate - d1).Days <= 3 Then
result = "yellow"
Else : result = "green"
End If
Upvotes: 1