How to: Respond to User Clicks in ImageMap Web Server Controls
You can configure an ImageMap control, or an individual region (hot spot) in it, so that when users click a specific hot spot, the control either goes to another page or performs a postback. You can override the control's settings for each hot spot.
If the ImageMap control or an individual hot spot has been configured to go to a specific URL, you do not have an opportunity to respond directly to the click. However, if the control or hot spot is configured to perform a postback, you can write a handler for the event and determine which hot spot was clicked.
To respond to a user click in an ImageMap control
-
Add a Click event handler for the ImageMap control. The second argument of the handler must be of type ImageMapEventArgs.
-
In the event handler, read the PostBackValue property of the ImageMapEventArgs object to determine which hot spot was clicked.
The following code example shows how to respond to a user click in an ImageMap control. The page contains an ImageMap control with four rectangular hot spots. Each hot spot's PostBackValue property is set to a unique value. The code in the handler checks for each value and displays an appropriate response.