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