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) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照


このページでは「.NET Framework クラス ライブラリ リファレンス」からRectangleHotSpot クラスを検索した結果を表示しています。
Weblioに収録されているすべての辞書からRectangleHotSpot クラスを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からRectangleHotSpot クラス を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「RectangleHotSpot クラス」の関連用語

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

   

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



RectangleHotSpot クラスのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS