RectangleHotSpotとは? わかりやすく解説

RectangleHotSpot クラス

メモ : このクラスは、.NET Framework version 2.0 で新しく追加されたものです。

ImageMap コントロールに四角形のホット スポット領域を定義します。このクラスは継承できません。

名前空間: System.Web.UI.WebControls
アセンブリ: System.Web (system.web.dll 内)
構文構文

Public NotInheritable Class
 RectangleHotSpot
    Inherits HotSpot
Dim instance As RectangleHotSpot
public sealed class RectangleHotSpot : HotSpot
public ref class RectangleHotSpot sealed :
 public HotSpot
public final class RectangleHotSpot extends
 HotSpot
public final class RectangleHotSpot extends
 HotSpot
解説解説

このクラスは、ImageMap コントロールに四角形のホット スポット領域を定義します。RectangleHotSpot オブジェクトの領域を定義するには、その四角形領域の左上隅の x 座標を表す値を Left プロパティに設定します。Top プロパティには、四角形領域の左上隅の y 座標を表す値を設定します。Right プロパティには、四角形領域の右下隅の x 座標を表す値を設定します。Bottom プロパティには、四角形領域の右下隅の y 座標を表す値を設定します。

RectangleHotSpot コントロールをクリックすると、URL へのページ移動、サーバーへのポストバックの生成が行われるか、または何も起こりません。この動作は、HotSpotMode プロパティで指定します。URL に移動するには、HotSpotMode プロパティを HotSpotMode.Navigate に設定し、NavigateUrl プロパティを使用して移動先の URL を指定します。サーバーへのポストバックを行うには、HotSpotMode プロパティを HotSpotMode.PostBack に設定し、PostBackValue プロパティを使用して、RectangleHotSpot オブジェクトの名前を指定します。この名前は、RectangleHotSpot がクリックされたときに、ImageMapEventArgs イベント データに渡されます。. HotSpot オブジェクトが何も動作を行わないようにするには、HotSpotMode プロパティを HotSpotMode.Inactive に設定します。

使用例使用例

2 つの RectangleHotSpot オブジェクトを含む ImageMap コントロールを、宣言によって作成する方法を次のコード例に示します。ImageMap.HotSpotMode プロパティは HotSpotMode.PostBack に設定されます。この場合、ユーザーがいずれかのホット スポット領域をクリックするたびに、ページがサーバーにポストバックされます。ユーザーがいずれかの RectangleHotSpot オブジェクトをクリックするたびに、GetCoordinates メソッドが呼び出され、選択されたホット スポットの座標がユーザーに表示されます。この例を正常に動作させるには、ImageUrl プロパティにユーザー独自のイメージを提供し、アプリケーションがそのイメージを見つけられるように、イメージへのパスを適切に更新する必要があります。

<%@ Page Language="VB" %>

<script runat="server">
  
  Sub VoteMap_Clicked(ByVal sender As
 Object, ByVal e As ImageMapEventArgs)
    Dim coordinates As String
    Dim hotSpotType As String
    Dim yescount As Integer
    Dim nocount As Integer
    
    If (ViewState("yescount") IsNot
 Nothing) Then
      yescount = Convert.ToInt32(ViewState("yescount"))
    Else
      yescount = 0
    End If
    If (ViewState("nocount") IsNot
 Nothing) Then
      nocount = Convert.ToInt32(ViewState("nocount"))
    Else
      nocount = 0
    End If
      
    
    ' When a user clicks the "Yes" hot spot,
    ' display the hot spot's name and coordinates.
    If (e.PostBackValue.Contains("Yes"))
 Then
      
      yescount += 1
      coordinates = Vote.HotSpots(0).GetCoordinates()
      hotSpotType = Vote.HotSpots(0).ToString()
      Message1.Text = "You selected " & hotSpotType
 & " " & e.PostBackValue & ".<br>"
 & _
                      "The coordinates are " &
 coordinates & ".<br>" & _
                      "The current vote count is "
 & yescount.ToString() & _
                      " yes votes and " & nocount.ToString()
 & " no votes."
       
      ' When a user clicks the "No" hot spot,
      ' display the hot spot's name and coordinates.
    ElseIf (e.PostBackValue.Contains("No"))
 Then
      
      nocount += 1
      coordinates = Vote.HotSpots.Item(1).GetCoordinates()
      hotSpotType = Vote.HotSpots.Item(1).ToString()
      Message1.Text = "You selected " & hotSpotType
 & " " & e.PostBackValue & ".<br>"
 & _
                     "The coordinates are " &
 coordinates & ".<br>" & _
                      "The current vote count is "
 & yescount.ToString() & _
                      " yes votes and " & nocount.ToString()
 & " no votes."
      
    Else
      
      Message1.Text = "You did not click a valid hot spot region."
                
    End If
      
    ViewState("yescount") = yescount
    ViewState("nocount") = nocount
    
  End Sub
  
</script>

<html>
<head id="Head1" runat="server">
  <title>ImageMap Class Post Back Example</title>
</head>
  <body>
    <form id="Form1" runat="server">
    
      <h3>ImageMap Class Post Back Example</h3>
      
      <asp:imagemap id="Vote"           
        imageurl="Images/VoteImage.jpg"
        width="400" 
        height="200" 
        alternatetext="Vote Yes or No"
        hotspotmode="PostBack"
        onclick="VoteMap_Clicked"
        runat="Server">            
          
        <asp:RectangleHotSpot          
          top="0"
          left="0"
          bottom="200"
          right="200"
          postbackvalue="Yes"
          alternatetext="Vote yes">
        </asp:RectangleHotSpot>
          
        <asp:RectangleHotSpot 
          top="0"
          left="201"
          bottom="200"
          right="400"
          postbackvalue="No"
          alternatetext="Vote no">
        </asp:RectangleHotSpot>
      
      </asp:imagemap>
            
      <br /><br />
          
      <asp:label id="Message1"
        runat="Server">
      </asp:label>                 
                 
    </form>      
  </body>
</html>
<%@ page language="C#" %>
<script runat="server">
  
  void VoteMap_Clicked (Object sender, ImageMapEventArgs e)
  {
    string coordinates;
    string hotSpotType;
    int yescount = ((ViewState["yescount"] != null)?
 (int)ViewState["yescount"] : 0);
    int nocount = ((ViewState["nocount"] != null)?
 (int)ViewState["nocount"] : 0);

    // When a user clicks the "Yes" hot spot,
    // display the hot spot's name and coordinates.
    if (e.PostBackValue.Contains("Yes"))
    {
      yescount += 1;
      coordinates = Vote.HotSpots[0].GetCoordinates();
      hotSpotType = Vote.HotSpots[0].ToString ();
      Message1.Text = "You selected " + hotSpotType + " " + e.PostBackValue
 + ".<br>" +
                      "The coordinates are " + coordinates + ".<br>"
 +
                      "The current vote count is " + yescount.ToString()
 + 
            " yes votes and " + nocount.ToString() + " no votes.";
    }
      
    // When a user clicks the "No" hot spot,
    // display the hot spot's name and coordinates.
    else if (e.PostBackValue.Contains("No"))
    {
      nocount += 1;
      coordinates = Vote.HotSpots[1].GetCoordinates();
      hotSpotType = Vote.HotSpots[1].ToString ();
      Message1.Text = "You selected " + hotSpotType + " " + e.PostBackValue
 + ".<br>" +
                      "The coordinates are " + coordinates + ".<br>"
 +
            "The current vote count is " + yescount.ToString() +
            " yes votes and " + nocount.ToString() + " no votes.";
    }
    
    else
    {
      Message1.Text = "You did not click a valid hot spot region.";
    }

    ViewState["yescount"] = yescount;
    ViewState["nocount"] = nocount;
  }           
  
</script>

<html>
<head id="Head1" runat="server">
  <title>ImageMap Class Post Back Example</title>
</head>
  <body>
    <form id="Form1" runat="server">
    
      <h3>ImageMap Class Post Back Example</h3>
      
      <asp:imagemap id="Vote"           
        imageurl="Images/VoteImage.jpg"
        width="400" 
        height="200" 
        alternatetext="Vote Yes or No"
        hotspotmode="PostBack"
        onclick="VoteMap_Clicked"
        runat="Server">            
          
        <asp:RectangleHotSpot          
          top="0"
          left="0"
          bottom="200"
          right="200"
          postbackvalue="Yes"
          alternatetext="Vote yes">
        </asp:RectangleHotSpot>
          
        <asp:RectangleHotSpot 
          top="0"
          left="201"
          bottom="200"
          right="400"
          postbackvalue="No"
          alternatetext="Vote no">
        </asp:RectangleHotSpot>
      
      </asp:imagemap>
            
      <br /><br />
          
      <asp:label id="Message1"
        runat="Server">
      </asp:label>                 
                 
    </form>      
  </body>
</html>
.NET Framework のセキュリティ.NET Framework のセキュリティ
継承階層継承階層
System.Object
   System.Web.UI.WebControls.HotSpot
    System.Web.UI.WebControls.RectangleHotSpot
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

RectangleHotSpot コンストラクタ

メモ : このコンストラクタは、.NET Framework version 2.0 で新しく追加されたものです。

RectangleHotSpot クラスの新しいインスタンスを初期化します。

名前空間: System.Web.UI.WebControls
アセンブリ: System.Web (system.web.dll 内)
構文構文

Dim instance As New RectangleHotSpot
public RectangleHotSpot ()
public:
RectangleHotSpot ()
public RectangleHotSpot ()
public function RectangleHotSpot ()
解説解説
使用例使用例

プログラムを使用して 2 つの RectangleHotSpot オブジェクトを作成し、それらのプロパティを設定し、ImageMap コントロールの HotSpotCollection コレクションに追加する方法を次のコード例に示します。この例を正常に動作させるには、ImageUrl プロパティにユーザー独自のイメージを提供し、アプリケーションがそのイメージを見つけられるように、イメージへのパスを適切に更新する必要があります。

<%@ page language="VB" %>

<script runat="server">
  
  Sub Page_Load(ByVal sender As
 Object, ByVal e As EventArgs)

    ' Programmatically create a RectangleHotSpot.
    Dim Rectangle1 As New
 RectangleHotSpot
    Rectangle1.Top = 0
    Rectangle1.Left = 0
    Rectangle1.Bottom = 200
    Rectangle1.Right = 200
    Rectangle1.PostBackValue = "Yes"
    Rectangle1.AlternateText = "Vote yes"
      
    ' Programmatically create a second RectangleHotSpot.
    Dim Rectangle2 As New
 RectangleHotSpot
    Rectangle2.Top = 0
    Rectangle2.Left = 201
    Rectangle2.Bottom = 200
    Rectangle2.Right = 400
    Rectangle2.PostBackValue = "No"
    Rectangle2.AlternateText = "Vote no"

    
    ' Add the RectangleHotSpot objects to the
    ' Vote ImageMap control's HotSpotCollection.
    Vote.HotSpots.Add(Rectangle1)
    Vote.HotSpots.Add(Rectangle2)
  
  End Sub
    
  Sub VoteMap_Clicked(ByVal sender As
 Object, ByVal e As ImageMapEventArgs)
    Dim hotSpotType As String
        
    ' When a user clicks the "Yes" hot spot,
    ' display the hot spot's name.
    If (e.PostBackValue = "Yes")
 Then
      hotSpotType = Vote.HotSpots(0).ToString()
      Message1.Text = "You selected " & hotSpotType
 & " " & e.PostBackValue & "."
       
      ' When a user clicks the "No" hot spot,
      ' display the hot spot's name.
    ElseIf (e.PostBackValue = "No")
 Then
      hotSpotType = Vote.HotSpots(1).ToString()
      Message1.Text = "You selected " & hotSpotType
 & " " & e.PostBackValue & "."
      
    Else
      Message1.Text = "You did not click in a valid hot spot region."
                
    End If
        
  End Sub
</script>

<html>
<head id="Head1" runat="server">
  <title>RectangleHotSpot VB Constructor Example</title>
</head>
  <body>
    <form id="Form1" runat="server">
    
      <h3>RectangleHotSpot Constructor Example</h3>
      
      <!-- Change or remove the width and
 height attributes as
           appropriate for your image. -->
      <asp:imagemap id="Vote"           
        imageurl="Images/VoteImage.jpg"
        alternatetext="Vote choices" 
        hotspotmode="PostBack"
        width="400"
        height="200"
        onclick="VoteMap_Clicked"   
        runat="Server">
      </asp:imagemap>
      
      <br />
                
      <asp:label id="Message1"
        runat="Server">
      </asp:label>                 
                 
    </form>      
  </body>
</html>
<%@ page language="C#" %>

<script runat="server">
  void Page_Load(object sender, EventArgs e)
  {
    // Programmatically create a RectangleHotSpot.
    RectangleHotSpot Rectangle1 = new RectangleHotSpot();
    Rectangle1.Top = 0;
    Rectangle1.Left = 0;
    Rectangle1.Bottom = 200;
    Rectangle1.Right = 200;
    Rectangle1.PostBackValue = "Yes";
    Rectangle1.AlternateText = "Vote yes";
      
    // Programmatically create a second RectangleHotSpot.
    RectangleHotSpot Rectangle2 = new RectangleHotSpot();
    Rectangle2.Top = 0;
    Rectangle2.Left = 201;
    Rectangle2.Bottom = 200;
    Rectangle2.Right = 400;
    Rectangle2.PostBackValue = "No";
    Rectangle2.AlternateText = "Vote no";
    
    // Add the RectangleHotSpot objects to the
    // Vote ImageMap control's HotSpotCollection.
    Vote.HotSpots.Add(Rectangle1);
    Vote.HotSpots.Add(Rectangle2);  
  }
  
  void VoteMap_Clicked (Object sender, ImageMapEventArgs e)
  {
    string hotSpotType;

    // When a user clicks the "Yes" hot spot,
    // display the hot spot's name.
    if (e.PostBackValue == "Yes")
    {
      hotSpotType = Vote.HotSpots[0].ToString ();
      Message1.Text = "You selected " + hotSpotType + " " + e.PostBackValue
 + "."; 
    }
      
    // When a user clicks the "No" hot spot,
    // display the hot spot's name.
    else if (e.PostBackValue == "No")
    {
      hotSpotType = Vote.HotSpots[1].ToString ();
      Message1.Text = "You selected " + hotSpotType + " " + e.PostBackValue
 + ".";
    }
    
    else
    {
      Message1.Text = "You did not click a valid hot spot region.";
    }
  }  

</script>

<html>
<head id="Head1" runat="server">
  <title>RectangleHotSpot C# Constructor Example</title>
</head>
  <body>
    <form id="Form1" runat="server">
    
      <h3>RectangleHotSpot Constructor Example</h3>
      
      <!-- Change or remove the width and height attributes as
           appropriate for your image. -->
      <asp:imagemap id="Vote"           
        imageurl="Images/VoteImage.jpg"
        alternatetext="Vote choices" 
        hotspotmode="PostBack"
        width="400"
        height="200"
        onclick="VoteMap_Clicked"   
        runat="Server">
      </asp:imagemap>
      
      <br />
                
      <asp:label id="Message1"
        runat="Server">
      </asp:label>                 
                 
    </form>      
  </body>
</html>
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

RectangleHotSpot プロパティ


パブリック プロパティパブリック プロパティ

  名前 説明
パブリック プロパティ AccessKey  HotSpot 領域にすばやく移動できるアクセス キーを取得または設定します。 ( HotSpot から継承されます。)
パブリック プロパティ AlternateText  イメージを使用できない場合や、イメージをサポートしないブラウザにイメージが表示される場合に、ImageMap コントロールの HotSpot オブジェクトに表示する代替テキストを取得または設定します。 ( HotSpot から継承されます。)
パブリック プロパティ Bottom RectangleHotSpot オブジェクトで定義される四角形領域の下辺の y 座標を取得または設定します。
パブリック プロパティ HotSpotMode  HotSpot がクリックされたときの、ImageMap コントロールの HotSpot オブジェクトの動作を取得または設定します。 ( HotSpot から継承されます。)
パブリック プロパティ Left RectangleHotSpot オブジェクトで定義される四角形領域の左辺の x 座標を取得または設定します。
パブリック プロパティ NavigateUrl  HotSpot オブジェクトがクリックされたときの移動先 URL を取得または設定します。 ( HotSpot から継承されます。)
パブリック プロパティ PostBackValue  HotSpot がクリックされたときにイベント データに渡される HotSpot オブジェクトの名前を取得または設定します。 ( HotSpot から継承されます。)
パブリック プロパティ Right RectangleHotSpot オブジェクトで定義される四角形領域の右辺の x 座標を取得または設定します。
パブリック プロパティ TabIndex  HotSpot 領域のタブ インデックスを取得または設定します。 ( HotSpot から継承されます。)
パブリック プロパティ Target  URL に移動する HotSpot オブジェクトがクリックされたときに、リンク先 Web ページの内容を表示するウィンドウまたはフレームを取得または設定します。 ( HotSpot から継承されます。)
パブリック プロパティ Top RectangleHotSpot オブジェクトで定義される四角形領域の上辺の y 座標を取得または設定します。
参照参照

関連項目

RectangleHotSpot クラス
System.Web.UI.WebControls 名前空間
ImageMap クラス
HotSpot.HotSpotMode プロパティ
Left
Top
Right
Bottom

その他の技術情報

ImageMap Web サーバー コントロール

RectangleHotSpot メソッド


パブリック メソッドパブリック メソッド

プロテクト メソッドプロテクト メソッド
参照参照

関連項目

RectangleHotSpot クラス
System.Web.UI.WebControls 名前空間
ImageMap クラス
HotSpot.HotSpotMode プロパティ
Left
Top
Right
Bottom

その他の技術情報

ImageMap Web サーバー コントロール

RectangleHotSpot メンバ

ImageMap コントロールに四角形のホット スポット領域を定義します。このクラスは継承できません。

RectangleHotSpot データ型で公開されるメンバを以下の表に示します。


パブリック コンストラクタパブリック コンストラクタ
  名前 説明
パブリック メソッド RectangleHotSpot RectangleHotSpot クラスの新しいインスタンスを初期化します。
パブリック プロパティパブリック プロパティ
  名前 説明
パブリック プロパティ AccessKey  HotSpot 領域にすばやく移動できるアクセス キーを取得または設定します。(HotSpot から継承されます。)
パブリック プロパティ AlternateText  イメージを使用できない場合や、イメージをサポートしないブラウザにイメージが表示される場合に、ImageMap コントロールの HotSpot オブジェクトに表示する代替テキストを取得または設定します。(HotSpot から継承されます。)
パブリック プロパティ Bottom RectangleHotSpot オブジェクトで定義される四角形領域の下辺の y 座標を取得または設定します。
パブリック プロパティ HotSpotMode  HotSpot がクリックされたときの、ImageMap コントロールの HotSpot オブジェクトの動作を取得または設定します。(HotSpot から継承されます。)
パブリック プロパティ Left RectangleHotSpot オブジェクトで定義される四角形領域の左辺の x 座標を取得または設定します。
パブリック プロパティ NavigateUrl  HotSpot オブジェクトがクリックされたときの移動先 URL を取得または設定します。(HotSpot から継承されます。)
パブリック プロパティ PostBackValue  HotSpot がクリックされたときにイベント データに渡される HotSpot オブジェクトの名前を取得または設定します。(HotSpot から継承されます。)
パブリック プロパティ Right RectangleHotSpot オブジェクトで定義される四角形領域の右辺の x 座標を取得または設定します。
パブリック プロパティ TabIndex  HotSpot 領域のタブ インデックスを取得または設定します。(HotSpot から継承されます。)
パブリック プロパティ Target  URL に移動する HotSpot オブジェクトがクリックされたときに、リンク先 Web ページの内容を表示するウィンドウまたはフレームを取得または設定します。(HotSpot から継承されます。)
パブリック プロパティ Top RectangleHotSpot オブジェクトで定義される四角形領域の上辺の y 座標を取得または設定します。
パブリック メソッドパブリック メソッド
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

RectangleHotSpot クラス
System.Web.UI.WebControls 名前空間
ImageMap クラス
HotSpot.HotSpotMode プロパティ
Left
Top
Right
Bottom

その他の技術情報

ImageMap Web サーバー コントロール



英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

「RectangleHotSpot」の関連用語

RectangleHotSpotのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



RectangleHotSpotのページの著作権

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.

©2026 GRAS Group, Inc.RSS