.NET Framework Class Library HotSpotMode Enumeration
Namespace:
System.Web.UI.WebControls
Assembly:
System.Web (in System.Web.dll)

Syntax
Public Enumeration HotSpotMode
public enum class HotSpotMode

Members
| Member name | Description |
|---|
| NotSet | The HotSpot uses the behavior set by the ImageMap control's HotSpotMode property. If the ImageMap control does not define the behavior, the HotSpot object navigates to a URL. | | Navigate | The HotSpot navigates to a URL. | | PostBack | The HotSpot generates a postback to the server. | | Inactive | The HotSpot does not have any behavior. |

Remarks
The HotSpotMode enumeration represents the behaviors that you can apply to a HotSpot object within an ImageMap control. The ImageMap..::.HotSpotMode and the HotSpot..::.HotSpotMode properties use these enumeration values to set the behavior of a HotSpot object when it is clicked. 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. If 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. 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. 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. Use the Image..::.NavigateUrl or the HotSpot..::.NavigateUrl property to specify the URL to navigate to. 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. Use the PostBackValue property to specify a name for the HotSpot object. This name will be passed in the ImageMapEventArgs event data when the postback event occurs. When a postback HotSpot is clicked, the Click event is raised. To programmatically control the actions performed when a postback HotSpot is clicked, provide an event handler for the Click event. If 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. This option is provided to allow you to create more complex hot spot zones within an ImageMap control. 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. 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>

Examples
The following code example demonstrates how to use the HotSpotMode enumeration values to set the ImageMap..::.HotSpotMode property. The page contains an ImageMap control that contains two RectangleHotSpot objects. 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 hot spot regions. The HotSpotMode property is not set on either of the RectangleHotSpot objects because they get their behavior from the ImageMap..::.HotSpotMode property. 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="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 >
<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="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 >
<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>

Version Information
.NET FrameworkSupported in: 4, 3.5, 3.0, 2.0

Platforms
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role not supported), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

See Also
|
Bibliothèque de classes .NET Framework HotSpotMode, énumération
Espace de noms :
System.Web.UI.WebControls
Assembly :
System.Web (dans System.Web.dll)

Syntaxe
Public Enumeration HotSpotMode
public enum class HotSpotMode

Membres
| Nom de membre | Description |
|---|
| NotSet | HotSpot utilise le comportement défini par la propriété HotSpotMode du contrôle ImageMap. Si le contrôle ImageMap ne définit pas le comportement, les objets HotSpot naviguent vers une URL. | | Navigate | HotSpot navigue vers une URL. | | PostBack | HotSpot génère une publication sur le serveur. | | Inactive | HotSpot ne possède pas de comportement. |

Notes
L'énumération HotSpotMode représente les comportements que vous pouvez appliquer à un objet HotSpot dans un contrôle ImageMap. Les propriétés ImageMap..::.HotSpotMode et HotSpot..::.HotSpotMode utilisent ces valeurs d'énumération pour définir le comportement d'un objet HotSpot suite à un clic. Si les deux propriétés sont définies, la propriété HotSpot..::.HotSpotMode spécifiée au niveau de chaque objet HotSpot individuel est prioritaire sur la propriété ImageMap..::.HotSpotMode du contrôle. Si vous spécifiez HotSpotMode.NotSet pour la propriété HotSpot..::.HotSpotMode d'un objet HotSpot individuel, le HotSpot obtient son comportement de la propriété ImageMap..::.HotSpotMode contenant le contrôle ImageMap. Dans ce scénario, si la propriété HotSpotMode du contrôle ImageMap a la valeur NotSet ou si aucune valeur n'est spécifiée, la navigation vers une URL est le comportement par défaut. Si vous spécifiez HotSpotMode.Navigate pour la propriété ImageMap..::.HotSpotMode ou la propriété HotSpot..::.HotSpotMode, la page navigue vers une URL lorsque vous cliquez sur HotSpot. Utilisez la propriété Image..::.NavigateUrl ou la propriété HotSpot..::.NavigateUrl pour spécifier l'URL à atteindre. Si vous spécifiez HotSpotMode.PostBack pour la propriété ImageMap..::.HotSpotMode ou la propriété HotSpot..::.HotSpotMode, la page génère une publication sur le serveur lorsque vous cliquez sur HotSpot. Utilisez la propriété PostBackValue pour spécifier un nom pour l'objet HotSpot. Ce nom est passé dans les données d'événement ImageMapEventArgs lorsque l'événement de publication se produit. En cas de clic sur un HotSpot de publication, l'événement Click est déclenché. Pour contrôler par programme les actions effectuées lorsqu'un clic a été effectué sur un HotSpot de publication, fournissez un gestionnaire d'événements pour l'événement Click. Si vous spécifiez HotSpotMode.Inactive pour la propriété HotSpot..::.HotSpotMode, lorsqu'un clic est effectué sur l'objet HotSpot, cet objet n'a pas de comportement. Vous pouvez utiliser cette valeur pour créer une zone réactive inactive dans une zone réactive active plus grande. Cette option vous permet de créer des zones réactives plus complexes dans un contrôle ImageMap. Pour créer une zone inactive dans une zone réactive active, vous devez spécifier la zone réactive inactive avant la zone active dans le contrôle ImageMap. Par exemple, le ImageMap suivant définit un cercle actif en spécifiant une zone réactive circulaire inactive dans une zone réactive circulaire active plus grande :
<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>

Exemples
L'exemple de code suivant montre comment utiliser les valeurs d'énumération HotSpotMode pour définir la propriété ImageMap..::.HotSpotMode. La page contient un contrôle ImageMap qui affiche deux objets RectangleHotSpot. La propriété ImageMap..::.HotSpotMode a la valeur HotSpotMode.PostBack, ce qui a pour effet de publier la page sur le serveur chaque fois qu'un utilisateur clique sur une zone réactive. La propriété HotSpotMode n'est pas définie pour les objets RectangleHotSpot parce qu'ils obtiennent leur comportement de la propriété ImageMap..::.HotSpotMode. Pour que cet exemple fonctionne correctement, vous devez fournir votre propre image pour la propriété ImageUrl et mettre à jour le chemin d'accès à l'image de façon à ce que l'application puisse la localiser.
<%@ 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 >
<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="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 >
<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>

Informations de version
.NET FrameworkPris en charge dans : 4, 3.5, 3.0, 2.0

Plateformes
Windows 7, Windows Vista SP1 ou ultérieur, Windows XP SP3, Windows XP SP2 Édition x64, Windows Server 2008 (installation minimale non prise en charge), Windows Server 2008 R2 (installation minimale prise en charge avec SP1 ou version ultérieure), Windows Server 2003 SP2
Le .NET Framework ne prend pas en charge toutes les versions de chaque plateforme. Pour obtenir la liste des versions prises en charge, consultez Configuration requise du .NET Framework.

Voir aussi
RéférenceAutres ressources
|