ImageMap Web Server Control
in ASP.NET environment,ImageMap Web Server control provides a technique you to create an image that has individual regions within the image which users can click; these regions are called hot spots. Each of these hot spots can be a separate hyperlink or postback event.
ImageMap Components
Basically, an ImageMap controls contains two parts such as Image and hot spots. Image can be a Graphic file such as .jpg,.png,.gif,etc. hot spots may be a hot spot set and each of which are different elements in which you must set a different shapes such as a circle, a square,etc. This shapes determines the location of the hot spots.
Customize user clicks
Then the next step is to set the User click events according to your needs. Each hot spots can be configured as a hyperlink that goes to a URL that you provide for that hot spot.
Alternatively, you can configure the control to perform a postback when a user clicks a hot spot, providing a unique value for each hot spot. The postback raises the ImageMap control's Click event. In the event handler, you can read the unique value that you assign to each hot spot.
- ToolTip -This is the text that is displayed in a ToolTip in some browsers.
- AlternateText -This is the text that is displayed if the graphics file cannot be found. If no ToolTip property is specified, some browsers will use the AlternateText value as a ToolTip.
- GenerateEmptyAlternateText -If this property is set to true, the alt attribute of the rendered image element will be set to an empty string.
To Add ImageMap Controls in a Page
- Type an <asp:ImageMap> element into the page.
- Set the control's ImageUrl property to the URL of a .gif, .jpg, or other Web graphic file.
- set the control's HotSpotMode property to specify whether clicking the hotspot results. This property such as Navigate, Postpack, NotSet, Inactive those are all optional
Specify Hotspots
- In the Properties window, click the HotSpots property box to display the HotSpot Collection Editor dialog box.
- Click the arrow button next to the Add button to select the type of hotspot that you want to create (CircleHotSpot, RectangleHotSpot, PolygonHotSpot).
- If you want to override the control's HotSpotMode setting, set the HotSpotMode property for each hotspot to specify whether clicking the hotspot results in navigation to another page or in a postback.
- If a hotspot is set to navigate, specify its NavigateUrl property.
- If a hotspot is set to perform a postback, set the PostBackValue for the hotspot to provide information about which hotspot is clicked. You can read the value in the Click event handler.
- click ok.
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 snippets describes how to Respond to user click via programmatically.
in .aspx page,