Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Get Image insted of color

Get Image insted of color

Scheduled Pinned Locked Moved ASP.NET
graphicshelpquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    duo
    wrote on last edited by
    #1

    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

    M 1 Reply Last reply
    0
    • D duo

      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

      M Offline
      M Offline
      Michael Sync
      wrote on last edited by
      #2

      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 If

      Hope 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. :)

      D 1 Reply Last reply
      0
      • M Michael Sync

        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 If

        Hope 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. :)

        D Offline
        D Offline
        duo
        wrote on last edited by
        #3

        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?

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups