Changing the imageurl of an imagemap control upon postback

B

BillGatesFan

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

Thanks!
 
N

Nathan Sokalski

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top