Get Image insted of color
-
In this code if a lot is occupied the label turns red and if not its green. But instead of using color i would like to use images to represent this change. Can any one Help??:laugh::laugh::laugh:
Dim sqlDataReader As Data.SqlClient.SqlDataReader= sqlLotStatus.EndExecuteReader() Dim lotStatus As String Dim textLabelName As String Dim colourLabelName As String Dim textLabelCtrl As Label Dim colourLabelCtrl As Label While sqlDataReader.Read() ' Derive label names. textLabelName = "Label" & sqlDataReader("Lot_id").ToString() & "Text" colourLabelName = "Label" & sqlDataReader("Lot_id").ToString() &"Colour" ' Get Label controls with derived names. textLabelCtrl = CType(Me.FindControl(textLabelName), Label) colourLabelCtrl = CType(Me.FindControl(colourLabelName), Label) ' Set control properties for lot. lotStatus = sqlDataReader("status").ToString() If lotStatus = "occupied" Then textLabelCtrl.Text = sqlDataReader("Lot_id").ToString() & " is not available" colourLabelCtrl.BackColor = Drawing.Color.Red Else textLabelCtrl.Text = sqlDataReader("Lot_id").ToString() & " is available" colourLabelCtrl.BackColor = Drawing.Color.Green End If End While
-
In this code if a lot is occupied the label turns red and if not its green. But instead of using color i would like to use images to represent this change. Can any one Help??:laugh::laugh::laugh:
Dim sqlDataReader As Data.SqlClient.SqlDataReader= sqlLotStatus.EndExecuteReader() Dim lotStatus As String Dim textLabelName As String Dim colourLabelName As String Dim textLabelCtrl As Label Dim colourLabelCtrl As Label While sqlDataReader.Read() ' Derive label names. textLabelName = "Label" & sqlDataReader("Lot_id").ToString() & "Text" colourLabelName = "Label" & sqlDataReader("Lot_id").ToString() &"Colour" ' Get Label controls with derived names. textLabelCtrl = CType(Me.FindControl(textLabelName), Label) colourLabelCtrl = CType(Me.FindControl(colourLabelName), Label) ' Set control properties for lot. lotStatus = sqlDataReader("status").ToString() If lotStatus = "occupied" Then textLabelCtrl.Text = sqlDataReader("Lot_id").ToString() & " is not available" colourLabelCtrl.BackColor = Drawing.Color.Red Else textLabelCtrl.Text = sqlDataReader("Lot_id").ToString() & " is available" colourLabelCtrl.BackColor = Drawing.Color.Green End If End While
duo!@# wrote:
instead of using color i would like to use images to represent this change.
then, use the image control instead of Label. OR. You can set the style to that label. Example : Style ~
<style type="text/css">
.TurnOn{
background : transparent url(http://url.com/ig/images/myimage.png) no-repeat;
}
</style>Code ~
If lotStatus = "occupied" Then
Label2.CssClass = "TurnOn";
Else
Label2.CssClass = "TurnOff";
End IfHope it helps..
Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you. :)
-
duo!@# wrote:
instead of using color i would like to use images to represent this change.
then, use the image control instead of Label. OR. You can set the style to that label. Example : Style ~
<style type="text/css">
.TurnOn{
background : transparent url(http://url.com/ig/images/myimage.png) no-repeat;
}
</style>Code ~
If lotStatus = "occupied" Then
Label2.CssClass = "TurnOn";
Else
Label2.CssClass = "TurnOff";
End IfHope it helps..
Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you. :)
Thank You For the code. But is there a way were i could use images instead of labels cos i intent to create a layout based view of a car park transparent url(http://url.com/ig/images/myimage.png) Wht is this for?