ImageMapEventArgs 클래스

정의

Click 컨트롤의 ImageMap 이벤트에 대한 데이터를 제공합니다.Provides data for the Click event of an ImageMap control.

public ref class ImageMapEventArgs : EventArgs
public class ImageMapEventArgs : EventArgs
type ImageMapEventArgs = class
    inherit EventArgs
Public Class ImageMapEventArgs
Inherits EventArgs
상속
ImageMapEventArgs

예제

다음 코드 예제에 대 한 이벤트 처리기를 만드는 방법을 보여 줍니다는 Click 이벤트입니다.The following code example demonstrates how to create an event handler for the Click event. 합니다 ImageMap 컨트롤에는 두 개의 RectangleHotSpot 개체입니다.The ImageMap control contains two RectangleHotSpot objects. ImageMap.HotSpotMode 속성이 HotSpotMode.PostBack, 중 하나를 클릭할 때마다 사용자는 서버에 다시 게시 하는 페이지에 이르게 합니다 RectangleHotSpot 개체입니다.The ImageMap.HotSpotMode property is set to HotSpotMode.PostBack, which causes the page to post back to the server each time a user clicks one of the RectangleHotSpot objects. 합니다 Click 이벤트를 처리 합니다 VoteMap_Clicked 이벤트 처리기입니다.The Click event is handled by the VoteMap_Clicked event handler. VoteMap_Clicked 검사를 PostBackValue 속성을 전송 합니다 ImageMapEventArgs 데이터를 결정 RectangleHotSpot 개체가 이벤트와 연결 된.The VoteMap_Clicked examines the PostBackValue property, sent in the ImageMapEventArgs data, to determine which RectangleHotSpot object is associated with the event. 이 예제가 제대로 작동 하려면 사용자 고유의 이미지를 제공 해야 합니다는 ImageUrl 속성 경로 업데이트 된 이미지를 적절 하 게 애플리케이션에서 찾을 수 있도록 합니다.For this example to work correctly, you must supply your own image for the ImageUrl property and update the path to the image appropriately so that the application can locate it.

<%@ 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 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 xmlns="http://www.w3.org/1999/xhtml" >
<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="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 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 xmlns="http://www.w3.org/1999/xhtml" >
<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>

설명

Click 이벤트가 발생 경우를 HotSpot 개체는 ImageMap 컨트롤을 클릭 합니다.The Click event is raised when a HotSpot object in an ImageMap control is clicked. 수 있도록를 HotSpot 발생 시키는 개체를 Click 이벤트를 먼저 설정 해야 합니다 ImageMap.HotSpotMode 속성 또는 HotSpot.HotSpotMode 속성을 HotSpotMode.PostBack합니다.To allow a HotSpot object to raise the Click event, you must first set either the ImageMap.HotSpotMode property or the HotSpot.HotSpotMode property to HotSpotMode.PostBack. 포스트백 할 때 수행 되는 프로그래밍 방식으로 동작을 제어할 수 HotSpot 는 클릭에 대 한 이벤트 처리기를 제공 합니다 Click 이벤트입니다.To control the actions programmatically that are performed when a postback HotSpot is clicked, provide an event handler for the Click event.

A PostBackValue 속성의 동작을 사용 하 여 연결 된 문자열을 저장 합니다 HotSpot 클릭할 때 개체입니다.A PostBackValue property stores a string that is associated with the behavior of the HotSpot object when clicked. 이 문자열은 전달 합니다 ImageMapEventArgs 이벤트 데이터 때는 HotSpot 를 클릭 합니다.This string is passed in the ImageMapEventArgs event data when the HotSpot is clicked.

생성자

ImageMapEventArgs(String)

ImageMapEventArgs 클래스의 새 인스턴스를 초기화합니다.Initializes a new instance of the ImageMapEventArgs class.

속성

PostBackValue

클릭된 String 개체의 PostBackValue 속성에 할당된 HotSpot을 가져옵니다.Gets the String assigned to the PostBackValue property of the HotSpot object that was clicked.

메서드

Equals(Object)

지정한 개체가 현재 개체와 같은지를 확인합니다.Determines whether the specified object is equal to the current object.

(다음에서 상속됨 Object)
GetHashCode()

기본 해시 함수로 작동합니다.Serves as the default hash function.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type을 가져옵니다.Gets the Type of the current instance.

(다음에서 상속됨 Object)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.Creates a shallow copy of the current Object.

(다음에서 상속됨 Object)
ToString()

현재 개체를 나타내는 string을 반환합니다.Returns a string that represents the current object.

(다음에서 상속됨 Object)

적용 대상

추가 정보