PolygonHotSpot PolygonHotSpot PolygonHotSpot PolygonHotSpot Class

Definition

Defines a polygon-shaped hot spot region in an ImageMap control. This class cannot be inherited.

public ref class PolygonHotSpot sealed : System::Web::UI::WebControls::HotSpot
public sealed class PolygonHotSpot : System.Web.UI.WebControls.HotSpot
type PolygonHotSpot = class
    inherit HotSpot
Public NotInheritable Class PolygonHotSpot
Inherits HotSpot
Inheritance
PolygonHotSpotPolygonHotSpotPolygonHotSpotPolygonHotSpot

Examples

The following code example demonstrates how to create an ImageMap control that contains three PolygonHotSpot objects. Each PolygonHotSpot object represents a geographical region on the map. When the user clicks a PolygonHotSpot object, it posts back to the server and the type and name of the hot spot are displayed in a label.

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
  
  void RegionMap_Clicked (object sender, ImageMapEventArgs e)
  {
    string hotSpotType;

    // When a user clicks a hot spot, display
    // the hot spot's type and name.
    switch (e.PostBackValue)
    {
      case "Western":
        hotSpotType = Regions.HotSpots[0].ToString();
        Message1.Text = "You selected " + hotSpotType + " " + e.PostBackValue;
        break;
        
      case "Northern":
        hotSpotType = Regions.HotSpots[1].ToString();
        Message1.Text = "You selected " + hotSpotType + " " + e.PostBackValue;
        break;

      case "Southern":
        hotSpotType = Regions.HotSpots[2].ToString();
        Message1.Text = "You selected " + hotSpotType + " " + e.PostBackValue;
        break;

      default:
        Message1.Text = "You did not click a valid hot spot region.";
        break;
    }
  }  
  
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
  <title>PolygonHotSpot Class Example</title>
</head>
  <body>
    <form id="Form1" runat="server">
    
      <h3>PolygonHotSpot Example</h3>
      
      <!-- Change or remove the width and height attributes as
           appropriate for your image. -->
      <asp:imagemap id="Regions"           
        imageurl="Images/RegionMap.jpg"
        alternatetext="Sales regions" 
        hotspotmode="PostBack"
        width="400"
        height="400"
        onclick="RegionMap_Clicked"   
        runat="Server">            
          
        <asp:PolygonHotSpot 
          coordinates="0,0,176,0,125,182,227,400,0,400"         
          postbackvalue="Western"
          alternatetext="Western Region">
        </asp:PolygonHotSpot>
          
        <asp:PolygonHotSpot 
          coordinates="177,0,400,0,400,223,335,154,127,180"         
          postbackvalue="Northern"
          alternatetext="Northern Region">
        </asp:PolygonHotSpot>
        
        <asp:PolygonHotSpot 
          coordinates="128,185,335,157,400,224,400,400,228,400"         
          postbackvalue="Southern"
          alternatetext="Southern Region">
        </asp:PolygonHotSpot>
      
      </asp:imagemap>
            
      <br /><br />
          
      <asp:label id="Message1"
        runat="Server">
      </asp:label>                 
                 
    </form>      
  </body>
</html>
<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
  
  Sub RegionMap_Clicked(ByVal sender As Object, ByVal e As ImageMapEventArgs)
    Dim hotSpotType As String
        
    ' When a user clicks a hot spot, display
    ' the hot spot's type and name.
    Select Case (e.PostBackValue)
      
      Case ("Western")
        hotSpotType = Regions.HotSpots(0).ToString()
        Message1.Text = "You selected " & hotSpotType & " " & e.PostBackValue
      
      Case ("Northern")
        hotSpotType = Regions.HotSpots(1).ToString()
        Message1.Text = "You selected " & hotSpotType & " " & e.PostBackValue
      
      Case ("Southern")
        hotSpotType = Regions.HotSpots(2).ToString()
        Message1.Text = "You selected " & hotSpotType & " " & e.PostBackValue
      
      Case Else
        Message1.Text = "You did not click a valid hot spot region."
    
    End Select

  End Sub
  
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
  <title>PolygonHotSpot Class Example</title>
</head>
  <body>
    <form id="Form1" runat="server">
    
      <h3>PolygonHotSpot Example</h3>
      
      <!-- Change or remove the width and height attributes as
           appropriate for your image. -->
      <asp:imagemap id="Regions"           
        imageurl="Images/RegionMap.jpg"
        alternatetext="Sales regions" 
        hotspotmode="PostBack"
        width="400"
        height="400"
        onclick="RegionMap_Clicked"   
        runat="Server">            
          
        <asp:PolygonHotSpot 
          coordinates="0,0,176,0,125,182,227,400,0,400"         
          postbackvalue="Western"
          alternatetext="Western Region">
        </asp:PolygonHotSpot>
          
        <asp:PolygonHotSpot 
          coordinates="177,0,400,0,400,223,335,154,127,180"         
          postbackvalue="Northern"
          alternatetext="Northern Region">
        </asp:PolygonHotSpot>
        
        <asp:PolygonHotSpot 
          coordinates="128,185,335,157,400,224,400,400,228,400"         
          postbackvalue="Southern"
          alternatetext="Southern Region">
        </asp:PolygonHotSpot>
      
      </asp:imagemap>
            
      <br /><br />
          
      <asp:label id="Message1"
        runat="Server">
      </asp:label>                 
                 
    </form>      
  </body>
</html>

Remarks

This class defines a polygon-shaped hot spot region in an ImageMap control. The PolygonHotSpot is useful for defining irregularly shaped hot spot regions in an ImageMap control. For example, you can use it to define individual regions within a geographical map.

To define the region of a PolygonHotSpot, set the Coordinates property to a string that specifies the coordinates of each vertex of the PolygonHotSpot object. A polygon vertex is a point at which two polygon edges meet.

When a PolygonHotSpot object is clicked, the page navigates to a URL, generates a post back to the server, or does nothing. The HotSpotMode property specifies this behavior. To navigate to a URL, set the HotSpotMode property to HotSpotMode.Navigate, and use the NavigateUrl property to specify the URL to navigate to. To post back to the server, set the HotSpotMode property to HotSpotMode.PostBack, and use the PostBackValue property to specify a name for the PolygonHotSpot object. This name will be passed in the ImageMapEventArgs event data when the PolygonHotSpot is clicked. If you want the PolygonHotSpot object to have no behavior, set the HotSpotMode property to HotSpotMode.Inactive.

Constructors

PolygonHotSpot() PolygonHotSpot() PolygonHotSpot() PolygonHotSpot()

Initializes a new instance of the PolygonHotSpot class.

Properties

AccessKey AccessKey AccessKey AccessKey

Gets or sets the access key that allows you to quickly navigate to the HotSpot region.

(Inherited from HotSpot)
AlternateText AlternateText AlternateText AlternateText

Gets or sets the alternate text to display for a HotSpot object in an ImageMap control when the image is unavailable or renders to a browser that does not support images.

(Inherited from HotSpot)
Coordinates Coordinates Coordinates Coordinates

A string of coordinates that represents the vertexes of a PolygonHotSpot object.

HotSpotMode HotSpotMode HotSpotMode HotSpotMode

Gets or sets the behavior of a HotSpot object in an ImageMap control when the HotSpot is clicked.

(Inherited from HotSpot)
IStateManager.IsTrackingViewState IStateManager.IsTrackingViewState IStateManager.IsTrackingViewState IStateManager.IsTrackingViewState

Gets a value indicating whether the HotSpot object is tracking its view-state changes.

(Inherited from HotSpot)
IsTrackingViewState IsTrackingViewState IsTrackingViewState IsTrackingViewState

Gets a value indicating whether the HotSpot object is tracking its view-state changes.

(Inherited from HotSpot)
MarkupName MarkupName MarkupName MarkupName

When overridden in a derived class, gets the string representation for the HotSpot object's shape.

(Inherited from HotSpot)
NavigateUrl NavigateUrl NavigateUrl NavigateUrl

Gets or sets the URL to navigate to when a HotSpot object is clicked.

(Inherited from HotSpot)
PostBackValue PostBackValue PostBackValue PostBackValue

Gets or sets the name of the HotSpot object to pass in the event data when the HotSpot is clicked.

(Inherited from HotSpot)
TabIndex TabIndex TabIndex TabIndex

Gets or sets the tab index of the HotSpot region.

(Inherited from HotSpot)
Target Target Target Target

Gets or sets the target window or frame in which to display the Web page content linked to when a HotSpot object that navigates to a URL is clicked.

(Inherited from HotSpot)
ViewState ViewState ViewState ViewState

Gets a dictionary of state information that allows you to save and restore the view state of a HotSpot object across multiple requests for the same page.

(Inherited from HotSpot)

Methods

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetCoordinates() GetCoordinates() GetCoordinates() GetCoordinates()

Returns a string that represents the coordinates of the vertexes of a PolygonHotSpot object.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
LoadViewState(Object) LoadViewState(Object) LoadViewState(Object) LoadViewState(Object)

Restores the HotSpot object's previously saved view state to the object.

(Inherited from HotSpot)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
SaveViewState() SaveViewState() SaveViewState() SaveViewState()

Saves the changes to the HotSpot object's view state since the time the page was posted back to the server.

(Inherited from HotSpot)
ToString() ToString() ToString() ToString()

Returns the String representation of this instance of a HotSpot object.

(Inherited from HotSpot)
TrackViewState() TrackViewState() TrackViewState() TrackViewState()

Causes the HotSpot object to track changes to its view state so they can be stored in the object's StateBag object. This object is accessible through the ViewState property.

(Inherited from HotSpot)

Explicit Interface Implementations

IStateManager.LoadViewState(Object) IStateManager.LoadViewState(Object) IStateManager.LoadViewState(Object) IStateManager.LoadViewState(Object)

Restores the HotSpot object's previously saved view state to the object.

(Inherited from HotSpot)
IStateManager.SaveViewState() IStateManager.SaveViewState() IStateManager.SaveViewState() IStateManager.SaveViewState()

Saves the changes to the HotSpot object's view state since the last time the page was posted back to the server.

(Inherited from HotSpot)
IStateManager.TrackViewState() IStateManager.TrackViewState() IStateManager.TrackViewState() IStateManager.TrackViewState()

Instructs the HotSpot region to track changes to its view state.

(Inherited from HotSpot)

Applies to

See also