RectangleHotSpot.Right プロパティ
アセンブリ: System.Web (system.web.dll 内)
構文
RectangleHotSpot オブジェクトで定義される四角形領域の右辺の x 座標。既定値は 0 です。
Right プロパティを使用すると、この RectangleHotSpot オブジェクトで定義される四角形領域の右辺の x 座標を表す値を取得または設定できます。RectangleHotSpot オブジェクトを完全に定義するには、このプロパティと Left、Top、および Bottom の各プロパティの値を指定する必要があります。
2 つの RectangleHotSpot オブジェクトを含む ImageMap コントロールを、宣言によって作成する方法を次のコード例に示します。1 つの RectangleHotSpot オブジェクトは宣言によって作成され、Right プロパティを含むプロパティが宣言によって設定されます。もう 1 つの RectangleHotSpot オブジェクトはプログラムによって作成され、Right プロパティを含むプロパティがプログラムによって設定されます。この例を正常に動作させるには、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 ' Set properties on Rectangle1. Rectangle1.Top = 0 Rectangle1.Left = 0 Rectangle1.Bottom = 200 Rectangle1.Right = 200 Rectangle1.PostBackValue = "Yes" Rectangle1.AlternateText = "Vote yes" ' Add the RectangleHotSpot object to the ' Vote ImageMap control's HotSpotCollection. Vote.HotSpots.Add(Rectangle1) End Sub Sub VoteMap_Clicked(ByVal sender As Object, ByVal e As ImageMapEventArgs) ' When a user clicks the "Yes" hot spot, ' display the hot spot's value. If (e.PostBackValue = "Yes") Then Message1.Text = "You selected " & e.PostBackValue & "." ' When a user clicks the "No" hot spot, ' display the hot spot's value. ElseIf (e.PostBackValue = "No") Then Message1.Text = "You selected " & e.PostBackValue & "." Else Message1.Text = "You did not click a valid hot spot region." End If End Sub </script> <html> <head id="Head1" runat="server"> <title>RectangleHotSpot Properties Example</title> </head> <body> <form id="Form1" runat="server"> <h3>RectangleHotSpot Properties Example</h3> <!-- Change or remove the width and height attributes as appropriate for your image. --> <asp:imagemap id="Vote" imageurl="Images/VoteImage.jpg" alternatetext="Voting choices" hotspotmode="PostBack" width="400" height="200" onclick="VoteMap_Clicked" runat="Server"> <asp:RectangleHotSpot top="0" left="201" bottom="200" right="400" postbackvalue="No" alternatetext="Vote no"> </asp:RectangleHotSpot> </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(); // Set properties on Rectangle1. Rectangle1.Top = 0; Rectangle1.Left = 0; Rectangle1.Bottom = 200; Rectangle1.Right = 200; Rectangle1.PostBackValue = "Yes"; Rectangle1.AlternateText = "Vote yes"; // Add the RectangleHotSpot object to the // Vote ImageMap control's HotSpotCollection. Vote.HotSpots.Add(Rectangle1); } void VoteMap_Clicked(object sender, ImageMapEventArgs e) { // When a user clicks the "Yes" hot spot, // display the hot spot's value. if (e.PostBackValue == "Yes") Message1.Text = "You selected " + e.PostBackValue + "."; else if (e.PostBackValue == "No") // When a user clicks the "No" hot spot, // display the hot spot's value. Message1.Text = "You selected " + e.PostBackValue + "."; else Message1.Text = "You did not click a valid hot spot region."; } </script> <html> <head id="Head1" runat="server"> <title>RectangleHotSpot Properties Example</title> </head> <body> <form id="Form1" runat="server"> <h3>RectangleHotSpot Properties Example</h3> <!-- Change or remove the width and height attributes as appropriate for your image. --> <asp:imagemap id="Vote" imageurl="Images/VoteImage.jpg" alternatetext="Voting choices" hotspotmode="PostBack" width="400" height="200" onclick="VoteMap_Clicked" runat="Server"> <asp:RectangleHotSpot top="0" left="201" bottom="200" right="400" postbackvalue="No" alternatetext="Vote no"> </asp:RectangleHotSpot> </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.Right プロパティのページへのリンク