ImageMap.HotSpots 屬性

定義

HotSpot 控制項取得定義作用點區域的 ImageMap 物件集合。

public:
 property System::Web::UI::WebControls::HotSpotCollection ^ HotSpots { System::Web::UI::WebControls::HotSpotCollection ^ get(); };
[System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerDefaultProperty)]
public System.Web.UI.WebControls.HotSpotCollection HotSpots { get; }
[<System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerDefaultProperty)>]
member this.HotSpots : System.Web.UI.WebControls.HotSpotCollection
Public ReadOnly Property HotSpots As HotSpotCollection

屬性值

HotSpotCollection 控制項表示定義作用點的 ImageMap 物件。

屬性

範例

下列程式碼範例示範如何以程式設計方式建立 控制項,並將兩 CircleHotSpotImageMap 物件加入其中。 屬性 HotSpots 是用來存取 HotSpotCollection 控制項的 ImageMap ,並將 物件加入 CircleHotSpot 其中。 若要讓這個範例正常運作,您必須提供屬性自己的映射 ImageUrl ,並適當地更新映射的路徑,讓應用程式可以找到它。

<%@ 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 Page_Load (Object sender, EventArgs e)
  {
    // Programmatically create an ImageMap control.
    ImageMap Shop = new ImageMap();
    
    // Set properties on the ImageMap control.
    Shop.ImageUrl = "Images/ShopChoice.jpg";
    Shop.AlternateText = "Shopping choices";

    // Add the ImageMap control to the 
    // Controls collection of the page.
    Page.Controls.Add(Shop);

    // Programmatically create a CircleHotSpot object.
    CircleHotSpot Circle1 = new CircleHotSpot();
    Circle1.HotSpotMode = HotSpotMode.Navigate;
    Circle1.NavigateUrl = "http://www.tailspintoys.com";
    Circle1.X = 145;
    Circle1.Y = 120;
    Circle1.Radius = 75;
    Circle1.AlternateText = "Shop for toys";

    // Add Circle1 to the ImageMap's HotSpotCollection.    
    Shop.HotSpots.Add(Circle1);

    // Programmatically create a second CircleHotSpot object.
    CircleHotSpot Circle2 = new CircleHotSpot();
    Circle2.HotSpotMode = HotSpotMode.Navigate;
    Circle2.NavigateUrl = "http://www.cohowinery.com";
    Circle2.X = 145;
    Circle2.Y = 290;
    Circle2.Radius = 75;
    Circle2.AlternateText = "Shop for wine";

    // Add Circle2 to the ImageMap's HotSpotCollection.    
    Shop.HotSpots.Add(Circle2);
  }

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="head1" runat="server">
  <title>ImageMap Class C# Constructor Example</title>
</head>
  <body>
    <form id="form1" runat="server">
    
      <h3>ImageMap Class C# Constructor Example</h3>
      
      <h4>Shopping Choices:</h4>
      
    </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 Page_Load(ByVal sender As Object, ByVal e As EventArgs)
    
    ' Programmatically create an ImageMap control.
    Dim Shop As New ImageMap
    Shop.ImageUrl = "Images/ShopChoice.jpg"
    Shop.AlternateText = "Shopping choices"
    
    ' Add the ImageMap control to the 
    ' Controls collection of the page.
    Page.Controls.Add(Shop)
    
    ' Programmatically create a CircleHotSpot object.
    Dim Circle1 As New CircleHotSpot
    Circle1.HotSpotMode = HotSpotMode.Navigate
    Circle1.NavigateUrl = "http://www.tailspintoys.com"
    Circle1.X = 145
    Circle1.Y = 120
    Circle1.Radius = 75
    Circle1.AlternateText = "Shop for toys"
    
    ' Add Circle1 to the ImageMap's HotSpotCollection.    
    Shop.HotSpots.Add(Circle1)
    
    ' Programmatically create a second CircleHotSpot object.
    Dim Circle2 As New CircleHotSpot
    Circle2.HotSpotMode = HotSpotMode.Navigate
    Circle2.NavigateUrl = "http://www.cohowinery.com"
    Circle2.X = 145
    Circle2.Y = 290
    Circle2.Radius = 75
    Circle2.AlternateText = "Shop for wine"

    
    ' Add Circle2 to the ImageMap's HotSpotCollection.    
    Shop.HotSpots.Add(Circle2)
    
  End Sub
  
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="head1" runat="server">
  <title>ImageMap Class VB Constructor Example</title>
</head>
  <body>
    <form id="form1" runat="server">
    
      <h3>ImageMap Class VB Constructor Example</h3>
      
      <h4>Shopping Choices:</h4>
      
    </form>      
  </body>
</html>

備註

HotSpots使用 屬性,以程式設計方式管理 控制項中的 ImageMap 作用點區域。 您可以使用 HotSpots 屬性來新增、插入、移除和擷取 HotSpot 物件。 如需詳細資訊,請參閱HotSpotCollection

適用於

另請參閱