ImageMap.HotSpotMode 属性

定义

获取或设置单击 HotSpot 对象时 ImageMap 控件的 HotSpot 对象的默认行为。Gets or sets the default behavior for the HotSpot objects of an ImageMap control when the HotSpot objects are clicked.

public:
 virtual property System::Web::UI::WebControls::HotSpotMode HotSpotMode { System::Web::UI::WebControls::HotSpotMode get(); void set(System::Web::UI::WebControls::HotSpotMode value); };
public virtual System.Web.UI.WebControls.HotSpotMode HotSpotMode { get; set; }
member this.HotSpotMode : System.Web.UI.WebControls.HotSpotMode with get, set
Public Overridable Property HotSpotMode As HotSpotMode

属性值

HotSpotMode 枚举值之一。One of the HotSpotMode enumeration values. 默认值为 NotSetThe default is NotSet.

异常

指定的类型不是 HotSpotMode 枚举值之一。The specified type is not one of the HotSpotMode enumeration values.

示例

下面的代码示例演示如何以声明方式创建ImageMap包含两个RectangleHotSpot对象的控件。The following code example demonstrates how to declaratively create 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 each 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对象的默认单击行为。 HotSpotModeUse the HotSpotMode property to specify the default click behavior of the HotSpot objects within an ImageMap control. 使用HotSpotMode枚举值之一设置此属性。This property is set using one of the HotSpotMode enumeration values. 下表列出了可能的值。The following table lists the possible values.

Item 说明Description
Inactive HotSpot对象没有任何行为。The HotSpot object does not have any behavior.
NotSet 对象使用由控件的HotSpotMode属性设置的行为。 ImageMap HotSpotThe HotSpot object uses the behavior set by the ImageMap control's HotSpotMode property. 如果控件未定义行为, 则对象将HotSpot导航到 URL。 ImageMapIf the ImageMap control does not define the behavior, the HotSpot objects all navigate to a URL.
Navigate HotSpot对象导航到 URL。The HotSpot objects navigate to a URL.
PostBack HotSpot对象生成到服务器的回发。The HotSpot objects generate a postback to the server.

HotSpot可以使用ImageMap控件的ImageMap.HotSpotMode属性或每个单独HotSpot的对象的HotSpot.HotSpotMode属性来指定对象的行为。You can specify a HotSpot object's behavior using either the ImageMap.HotSpotMode property of the ImageMap control or the HotSpot.HotSpotMode property of each individual HotSpot object. 如果同时设置了这两个HotSpot.HotSpotMode属性, 则HotSpot每个对象上指定的属性ImageMap.HotSpotMode将优先ImageMap于控件上的属性。If both properties are set, the HotSpot.HotSpotMode property specified on each individual HotSpot object takes precedence over the ImageMap.HotSpotMode property on the ImageMap control.

HotSpotMode在设置ImageMap 控件的HotSpotMode.Navigate属性时, 请注意,和值具有相同的行为:导航到URL。HotSpotMode.NotSetWhen you set the HotSpotMode property of the ImageMap control, note that the HotSpotMode.NotSet and HotSpotMode.Navigate values have the same behavior: both navigate to a URL. HotSpotMode.NotSet单个HotSpot.HotSpotMode HotSpot ImageMap对象的属性指定时, 将从控件的HotSpotMode属性的值确定其行为。 HotSpotWhen you specify HotSpotMode.NotSet for the HotSpot.HotSpotMode property of an individual HotSpot object, that HotSpot determines its behavior from the value of the HotSpotMode property of the ImageMap control.

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

如果HotSpotMode.PostBack HotSpot为属性指定, 则在单击时, 该页会生成到服务器的回发。 ImageMap.HotSpotModeIf you specify HotSpotMode.PostBack for the ImageMap.HotSpotMode property, the page generates a postback to the server when the HotSpot is clicked. PostBackValue使用属性指定作用点区域的名称。Use the PostBackValue property to specify the name of the hot spot region. 发生回发事件时, ImageMapEventArgs将在事件数据中传递此名称。This name will be passed in the ImageMapEventArgs event data when a 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 hot spot 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>  

若要使HotSpot ImageMap控件中的所有对象都具有相同的行为, 请HotSpotMode ImageMap使用控件上的属性来指定行为。To cause all HotSpot objects in an ImageMap control to have the same behavior, use the HotSpotMode property on the ImageMap control to specify the behavior. 然后, 将每个HotSpotMode单独HotSpot对象的属性设置为HotSpotMode.NotSet , HotSpot.HotSpotMode或者不指定属性的值。Then, either set the HotSpotMode property on each individual HotSpot object to HotSpotMode.NotSet or do not specify a value for the HotSpot.HotSpotMode property.

若要为ImageMap控件中HotSpot的对象指定不同的行为, HotSpot.HotSpotMode请将每个HotSpot单独对象的HotSpotMode.Navigate属性HotSpotMode.PostBack设置为HotSpotMode.Inactive、或。To specify different behaviors for HotSpot objects in an ImageMap control, set the HotSpot.HotSpotMode property on each individual HotSpot object to either HotSpotMode.Navigate, HotSpotMode.PostBack, or HotSpotMode.Inactive.

备注

HotSpot HotSpotMode.Navigate HotSpot.HotSpotMode如果控件的ImageMap.HotSpotMode属性或它所包含的任何对象的属性均设置为HotSpotMode.NotSet或未设置为值, 则默认情况下该行为是。 ImageMapIf an ImageMap control's ImageMap.HotSpotMode property or the HotSpot.HotSpotMode property on any of the HotSpot objects it contains is either set to HotSpotMode.NotSet or not set to a value, by default the behavior is HotSpotMode.Navigate.

适用于

另请参阅