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. Dynamically Setting Images on an ASP net site

Dynamically Setting Images on an ASP net site

Scheduled Pinned Locked Moved ASP.NET
data-structureshelp
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.
  • R Offline
    R Offline
    Reanalyse
    wrote on last edited by
    #1

    I have a large array of Imagebuttons on an ASPX page, that have the URL set depending upon the value of a variable The value matches the name of the ImageButton as below. Rather than the convoluted code as below is there a way to somehow dynamically change the button - something like ImageButton[mapflag].ImageUrl="warning.gif" if (mapflag == "TV1_ANALOGUE") TV1_ANALOGUE.ImageUrl = "warning.gif"; if (mapflag == "TV1_DTT") TV1_DTT.ImageUrl = "warning.gif"; if (mapflag == "TV1_DTH") TV1_DTH.ImageUrl = "warning.gif"; if (mapflag == "TV1_FM") TV1_FM.ImageUrl = "warning.gif"; if (mapflag == "TV1_LINKING") TV1_LINKING.ImageUrl = "warning.gif"; if (mapflag == "TV1_ISN") TV1_ISN.ImageUrl = "warning.gif"; if (mapflag == "TV1_EXTEND") TV1_EXTEND.ImageUrl = "warning.gif"; if (mapflag == "TV2_ANALOGUE") TV2_ANALOGUE.ImageUrl = "warning.gif"; if (mapflag == "TV2_DTT") TV2_DTT.ImageUrl = "warning.gif"; if (mapflag == "TV2_DTH") TV2_DTH.ImageUrl = "warning.gif"; if (mapflag == "TV2_FM") TV2_FM.ImageUrl = "warning.gif"; Many thanks for any help

    C 1 Reply Last reply
    0
    • R Reanalyse

      I have a large array of Imagebuttons on an ASPX page, that have the URL set depending upon the value of a variable The value matches the name of the ImageButton as below. Rather than the convoluted code as below is there a way to somehow dynamically change the button - something like ImageButton[mapflag].ImageUrl="warning.gif" if (mapflag == "TV1_ANALOGUE") TV1_ANALOGUE.ImageUrl = "warning.gif"; if (mapflag == "TV1_DTT") TV1_DTT.ImageUrl = "warning.gif"; if (mapflag == "TV1_DTH") TV1_DTH.ImageUrl = "warning.gif"; if (mapflag == "TV1_FM") TV1_FM.ImageUrl = "warning.gif"; if (mapflag == "TV1_LINKING") TV1_LINKING.ImageUrl = "warning.gif"; if (mapflag == "TV1_ISN") TV1_ISN.ImageUrl = "warning.gif"; if (mapflag == "TV1_EXTEND") TV1_EXTEND.ImageUrl = "warning.gif"; if (mapflag == "TV2_ANALOGUE") TV2_ANALOGUE.ImageUrl = "warning.gif"; if (mapflag == "TV2_DTT") TV2_DTT.ImageUrl = "warning.gif"; if (mapflag == "TV2_DTH") TV2_DTH.ImageUrl = "warning.gif"; if (mapflag == "TV2_FM") TV2_FM.ImageUrl = "warning.gif"; Many thanks for any help

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Building a map of strings to buttons is about your only option, unless you have an event and can make the button the tag for the event that causes this to happen

      Christian Graus Driven to the arms of OSX by Vista. "! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums. I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp

      R 1 Reply Last reply
      0
      • C Christian Graus

        Building a map of strings to buttons is about your only option, unless you have an event and can make the button the tag for the event that causes this to happen

        Christian Graus Driven to the arms of OSX by Vista. "! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums. I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp

        R Offline
        R Offline
        Reanalyse
        wrote on last edited by
        #3

        Thanks Christian I was afraid that was the case

        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