System.Web.UI.WebControls Namespace
.NET Framework version 2.0
Creates a control that displays an image on a page. When a hot spot region defined within the ImageMap control is clicked, the control either generates a postback to the server or navigates to a specified URL.
Visibility |
Constructor |
Parameters |
public |
ImageMap |
( )
|
|
Use the ImageMap control to create an image that contains defined hot spot regions. When a user clicks a hot spot region, the control can either generate a postback to the server or navigate to a specified URL.
For example, you can use this control to display a map of a geographical region. When a user clicks a specific region on the map, the control navigates to a URL that provides additional data about the selected region.
You can also use this control to generate a postback to the server and run specific code based on the hot spot region that was clicked. For example, you can use an ImageMap control to capture user responses such as votes. When a user clicks the hot spot region defined for yes votes, code is called to record a yes response in a database. When a user clicks on the hot spot region defined for no votes, a no response is recorded.
You can also mix these two scenarios within a single ImageMap control. For example, you can specify one hot spot region to navigate to a URL and another hot spot region to post back to the server.
Use the ImageUrl property to specify the path to the image to display for the ImageMap control.
You can define any number of HotSpot objects within an ImageMap control. You can use the CircleHotSpot, RectangleHotSpot, and PolygonHotSpot classes to define hot spot regions. Alternatively, you can derive from the abstract HotSpot class to define your own custom hot spot object.
There are two ways to specify the behavior of a HotSpot object in an ImageMap control when the HotSpot is clicked. You can use either the HotSpotMode property on the ImageMap control or the HotSpotMode property on an individual HotSpot object. These properties are set using one of the HotSpotMode enumeration values. If both properties are set, the HotSpotMode property specified on each individual HotSpot object takes precedence over the HotSpotMode property on the ImageMap control.
To navigate to a URL, set either the ImageMap.HotSpotMode property or the HotSpot.HotSpotMode property to HotSpotMode.Navigate. Use the NavigateUrl property to specify the URL to navigate to.
To generate a postback to the server, set either the ImageMap.HotSpotMode property or the HotSpot.HotSpotMode property to HotSpotMode.Postback. Use the PostBackValue property to specify a name for the hot spot region. This name will be passed in the ImageMapEventArgs event data when a postback event occurs. When a postback HotSpot is clicked, the Click event is raised. To programmatically control the actions performed when a postback HotSpot is clicked, provide an event handler for the Click event.
To cause all HotSpot objects in an ImageMap control to have the same behavior, use the ImageMap.HotSpotMode property to specify the behavior. Then, either set the HotSpot.HotSpotMode property on each individual HotSpot object to HotSpotMode.NotSet or do not specify a value for the HotSpot.HotSpotMode property.
To specify different behaviors for HotSpot objects in an ImageMap, set the HotSpot.HotSpotMode property on each individual HotSpot object to either HotSpotMode.Navigate or HotSpotMode.PostBack.
NOTE: If an ImageMap control's ImageMap.HotSpotMode property or the HotSpot.HotSpotMode property on any of the HotSpot objects it contains is set to HotSpotMode.NotSet or is not set to a value, by default the behavior is HotSpotMode.Navigate.
For examples illustrating use of this control, see the individual member types of this class. For syntax information, see ImageMap in ASP.NET Syntax for Web Controls.
ImageMap Web Server Control