HotSpotMode 枚举

定义

指定单击 HotSpotImageMap 控件中 HotSpot 对象的行为。Specifies the behaviors of a HotSpot object in an ImageMap control when the HotSpot is clicked.

public enum class HotSpotMode
public enum HotSpotMode
type HotSpotMode = 
Public Enum HotSpotMode
继承
HotSpotMode

字段

Inactive 3

HotSpot 不具有任何行为。The HotSpot does not have any behavior.

Navigate 1

HotSpot 定位到 URL。The HotSpot navigates to a URL.

NotSet 0

HotSpot 使用由 ImageMap 控件的 HotSpotMode 属性设置的行为。The HotSpot uses the behavior set by the ImageMap control's HotSpotMode property. 如果 ImageMap 控件未定义行为,HotSpot 对象将定位到 URL。If the ImageMap control does not define the behavior, the HotSpot object navigates to a URL.

PostBack 2

HotSpot 生成到服务器的回发。The HotSpot generates a postback to the server.

示例

下面的代码示例演示如何使用HotSpotMode枚举值来ImageMap.HotSpotMode设置属性。The following code example demonstrates how to use the HotSpotMode enumeration values to set the ImageMap.HotSpotMode property. 页面包含一个ImageMap包含两个RectangleHotSpot对象的控件。The page contains an ImageMap control that contains two RectangleHotSpot objects. 属性设置为HotSpotMode.PostBack, 这会使页面在用户每次单击其中一个作用点区域时回发到服务器。 ImageMap.HotSpotModeThe 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 hot spot regions. 不会在任何一个RectangleHotSpot对象上设置ImageMap.HotSpotMode 属性,因为它们从属性获取了其行为。HotSpotModeThe HotSpotMode property is not set on either of the RectangleHotSpot objects because they get their behavior from the ImageMap.HotSpotMode property. 若要使此示例正常工作, 必须为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)
  {       
    // 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 xmlns="http://www.w3.org/1999/xhtml" >
<head id="head1" runat="server">
  <title>ImageMap.HotSpotMode Example</title>
</head>
  <body>
    <form id="form1" runat="server">
    
      <h3>ImageMap.HotSpotMode Example</h3>
      
      <!--The RectangleHotSpot objects have the post back
        behavior specified by the HotSpotMode 
        property on the ImageMap control.-->
      <asp:imagemap id="Vote"           
        imageurl="Images/VoteImage.jpg"
        alternatetext="Voting choices" 
        hotspotmode="PostBack"
        onclick="VoteMap_Clicked"   
        runat="Server">   
        
        <asp:RectangleHotSpot          
          top="0"
          left="0"
          bottom="354"
          right="250"
          postbackvalue="Yes"
          alternatetext="Vote yes">
        </asp:RectangleHotSpot>
        
        <asp:RectangleHotSpot 
          top="0"
          left="251"
          bottom="354"
          right="500"
          postbackvalue="No"
          alternatetext="Vote no">
        </asp:RectangleHotSpot>
        
      </asp:imagemap>
      
      <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)
            
    ' 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 xmlns="http://www.w3.org/1999/xhtml" >
<head id="head1" runat="server">
  <title>ImageMap.HotSpotMode Example</title>
</head>
  <body>
    <form id="form1" runat="server">
    
      <h3>ImageMap.HotSpotMode Example</h3>
      
      <!--The RectangleHotSpot objects have the post back
        behavior specified by the HotSpotMode 
        property on the ImageMap control.-->
      <asp:imagemap id="Vote"           
        imageurl="Images/VoteImage.jpg"
        alternatetext="Voting choices" 
        hotspotmode="PostBack"
        onclick="VoteMap_Clicked"   
        runat="Server">   
        
        <asp:RectangleHotSpot          
          top="0"
          left="0"
          bottom="354"
          right="250"
          postbackvalue="Yes"
          alternatetext="Vote yes">
        </asp:RectangleHotSpot>
        
        <asp:RectangleHotSpot 
          top="0"
          left="251"
          bottom="354"
          right="500"
          postbackvalue="No"
          alternatetext="Vote no">
        </asp:RectangleHotSpot>
        
      </asp:imagemap>
      
      <br />
      
      <asp:label id="Message1"
        runat="Server">
      </asp:label>
              
    </form>      
  </body>
</html>

注解

枚举表示可应用于ImageMap控件内的HotSpot对象的行为。 HotSpotModeThe HotSpotMode enumeration represents the behaviors that you can apply to a HotSpot object within an ImageMap control. 和属性使用这些枚举值在单击HotSpot对象时设置其行为。 HotSpot.HotSpotMode ImageMap.HotSpotModeThe ImageMap.HotSpotMode and the HotSpot.HotSpotMode properties use these enumeration values to set the behavior of a HotSpot object when it is clicked. 如果同时设置了这两个HotSpot.HotSpotMode属性, 则HotSpot每个对象上指定的属性ImageMap.HotSpotMode将优先于控件上的属性。If both properties are set, the HotSpot.HotSpotMode property specified on each individual HotSpot object takes precedence over the ImageMap.HotSpotMode property on the control.

如果HotSpotMode.NotSet ImageMap HotSpot为单个对象HotSpotImageMap.HotSpotMode属性指定, 则将从包含控件的属性中获取其行为。 HotSpot.HotSpotModeIf you specify HotSpotMode.NotSet for the HotSpot.HotSpotMode property of an individual HotSpot object, the HotSpot gets its behavior from the containing ImageMap control's ImageMap.HotSpotMode property. 在这种情况下, ImageMap如果控件HotSpotMode的属性为NotSet或未指定任何值, 则默认行为是导航到 URL。In this scenario, if the ImageMap control's HotSpotMode property is either NotSet or no value is specified, the default behavior is to navigate to a URL.

备注

HotSpot.HotSpotMode HotSpot HotSpotMode.Navigate如果未使用ImageMap.HotSpotMode属性或属性所包含的对象的属性指定控件的行为,则默认情况下该行为是。ImageMapIf an ImageMap control's behavior is not specified using either the ImageMap.HotSpotMode property or the HotSpot.HotSpotMode property on the HotSpot objects it contains, by default the behavior is HotSpotMode.Navigate. 此外HotSpot.HotSpotMode , 如果ImageMap控件包含的HotSpot对象的属性设置ImageMap.HotSpotModeHotSpotMode.NotSet , 并且没有为属性指定任何值, 则默认行为是HotSpotMode.NavigateIn addition, if the HotSpot.HotSpotMode properties on the HotSpot objects that an ImageMap control contains are set to HotSpotMode.NotSet and no value is specified for the ImageMap.HotSpotMode property, the default behavior is HotSpotMode.Navigate.

HotSpotMode.Navigate如果为ImageMap.HotSpotMode属性或HotSpot.HotSpotMode属性指定, 则单击时HotSpot页面将导航到 URL。If you specify HotSpotMode.Navigate for either the ImageMap.HotSpotMode property or the HotSpot.HotSpotMode property, the page navigates to a URL when the HotSpot is clicked. Image.NavigateUrl 使用HotSpot.NavigateUrl或属性指定要导航到的 URL。Use the Image.NavigateUrl or the HotSpot.NavigateUrl property to specify the URL to navigate to.

HotSpotMode.PostBack如果为ImageMap.HotSpotMode属性或HotSpot.HotSpotMode属性指定, 则在单击时, 该页HotSpot会生成到服务器的回发。If you specify HotSpotMode.PostBack for either the ImageMap.HotSpotMode property or the HotSpot.HotSpotMode property, the page generates a postback to the server when the HotSpot is clicked. 使用属性指定HotSpot对象的名称。 PostBackValueUse the PostBackValue property to specify a name for the HotSpot object. 在回发事件发生时, ImageMapEventArgs此名称将在事件数据中传递。This name will be passed in the ImageMapEventArgs event data when the postback event occurs. 当单击回HotSpot发时Click , 将引发事件。When a postback HotSpot is clicked, the Click event is raised. 若要以编程方式控制在单击回HotSpot发时执行的操作, 请为Click事件提供事件处理程序。To programmatically control the actions performed when a postback HotSpot is clicked, provide an event handler for the Click event.

如果HotSpotMode.Inactive HotSpot为属性指定, 则在单击对象时, 该对象不会有任何行为。 HotSpot.HotSpotModeIf you specify HotSpotMode.Inactive for the HotSpot.HotSpotMode property, the HotSpot object does not have any behavior when it is clicked. 您可以使用此值在较大的活动作用点内创建非活动热点。You can use this value to create an inactive hot spot within a larger active hot spot. 提供此选项是为了使你能够在控件中创建更复杂的ImageMap作用点区域。This option is provided to allow you to create more complex hot spot zones within an ImageMap control.

若要在活动作用点内创建非活动区域, 必须在ImageMap控件中的活动热点之前指定非活动作用点。To create an inactive area within an active hot spot, you must specify the inactive hot spot before the active one in the ImageMap control. 例如, 以下ImageMap内容通过在较大的活动循环作用点中指定非活动的循环作用点来定义活动环:For example, the following ImageMap defines an active ring by specifying an inactive circular hot spot within a larger active circular hot spot:

<asp:ImageMap ID="SaturnImage"   
       ImageUrl="~/saturn.PNG"   
       runat="server" OnClick="SaturnImage_Click">  
    <asp:CircleHotSpot AlternateText="planet" HotSpotMode=PostBack  
          PostBackValue="planet" Radius=40 X=100 Y=100 />  
  
    <asp:CircleHotSpot HotSpotMode=Inactive   
          Radius=60 X=100 Y=100 />  
    <asp:CircleHotSpot AlternateText="rings" HotSpotMode=PostBack  
          PostBackValue="rings" Radius=80 X=100 Y=100 />  
</asp:ImageMap>  

适用于

另请参阅