Export (0) Print
Expand All

PolygonHotSpot Class

Note: This class is new in the .NET Framework version 2.0.

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

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in system.web.dll)

public sealed class PolygonHotSpot : HotSpot
public final class PolygonHotSpot extends HotSpot
public final class PolygonHotSpot extends HotSpot

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.

TopicLocation
How to: Add ImageMap Web Server Controls to a Web Forms PageBuilding ASP .NET Web Applications
How to: Add ImageMap Web Server Controls to a Web Forms PageBuilding ASP .NET Web Applications

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#" %>

<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>
<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>

System.Object
   System.Web.UI.WebControls.HotSpot
    System.Web.UI.WebControls.PolygonHotSpot

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0

Community Additions

ADD
Show:
© 2014 Microsoft