RectangleHotSpot クラス
アセンブリ: System.Web (system.web.dll 内)
構文
解説このクラスは、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 のセキュリティ
継承階層System.Web.UI.WebControls.HotSpot
System.Web.UI.WebControls.RectangleHotSpot
スレッド セーフ
プラットフォーム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
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
参照RectangleHotSpot コンストラクタ
アセンブリ: System.Web (system.web.dll 内)
構文
解説
使用例プログラムを使用して 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>
プラットフォーム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
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
参照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 メソッド
パブリック メソッド| 名前 | 説明 | |
|---|---|---|
| Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 ( Object から継承されます。) |
| GetCoordinates | オーバーライドされます。 RectangleHotSpot オブジェクトの左上隅の x 座標と y 座標、および右下隅の x 座標と y 座標を表す文字列を返します。 |
| GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 ( Object から継承されます。) |
| GetType | 現在のインスタンスの Type を取得します。 ( Object から継承されます。) |
| ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。) |
| ToString | HotSpot オブジェクトのこのインスタンスの String 表現を返します。 ( HotSpot から継承されます。) |
プロテクト メソッド| 名前 | 説明 | |
|---|---|---|
| Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 ( Object から継承されます。) |
| MemberwiseClone | 現在の Object の簡易コピーを作成します。 ( Object から継承されます。) |
参照RectangleHotSpot メンバ
ImageMap コントロールに四角形のホット スポット領域を定義します。このクラスは継承できません。
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 座標を取得または設定します。 |
パブリック メソッド| 名前 | 説明 | |
|---|---|---|
| Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 (Object から継承されます。) |
| GetCoordinates | オーバーライドされます。 RectangleHotSpot オブジェクトの左上隅の x 座標と y 座標、および右下隅の x 座標と y 座標を表す文字列を返します。 |
| GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 (Object から継承されます。) |
| GetType | 現在のインスタンスの Type を取得します。 (Object から継承されます。) |
| ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。) |
| ToString | HotSpot オブジェクトのこのインスタンスの String 表現を返します。 (HotSpot から継承されます。) |
プロテクト メソッド| 名前 | 説明 | |
|---|---|---|
| Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 (Object から継承されます。) |
| MemberwiseClone | 現在の Object の簡易コピーを作成します。 (Object から継承されます。) |
参照- RectangleHotSpotのページへのリンク