Changing the imageurl of an imagemap control upon postback

  • Thread starter Thread starter BillGatesFan
  • Start date Start date
B

BillGatesFan

Is there a way to change to swapimages for an imagemap in asp.net upon
postback on the server?

Thanks!
 
Try something like the following:

If Me.Image1.ImageUrl = "images/image1.gif" Then Me.Image1.ImageUrl =
"images/image2.gif" Else Me.Image1.ImageUrl = "images/image2.gif"

It is important to make sure EnableViewState is set to True so that you can
determine the currently displayed ImageUrl. If you have more than one image
you want to loop through, you will need to modify the algorithm a little,
but the key is looking at the currently displayed ImageUrl. Another approach
would be to use a HiddenField control to keep track of the currently
displayed image, but this requires an extra control, so it is probably less
efficient.
 
Back
Top