RectangleHotSpot Classe
Definição
public ref class RectangleHotSpot sealed : System::Web::UI::WebControls::HotSpot
public sealed class RectangleHotSpot : System.Web.UI.WebControls.HotSpot
type RectangleHotSpot = class
inherit HotSpot
Public NotInheritable Class RectangleHotSpot
Inherits HotSpot
- Herança
Exemplos
O exemplo de código a seguir demonstra como criar declarativamente um ImageMap controle que contém dois RectangleHotSpot objetos.The following code example demonstrates how to declaratively create an ImageMap control that contains two RectangleHotSpot objects. A ImageMap.HotSpotMode propriedade é definida como HotSpotMode.PostBack , o que faz com que a página seja reposta ao servidor sempre que um usuário clicar em uma das regiões de ponto de acesso.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. Cada vez que o usuário clica em um dos RectangleHotSpot objetos, o GetCoordinates método é chamado e as coordenadas do ponto de acesso selecionado são exibidas para o usuário.Each time the user clicks one of the RectangleHotSpot objects, the GetCoordinates method is called and the coordinates of the selected hot spot are displayed to the user. Para que este exemplo funcione corretamente, você deve fornecer sua própria imagem para a ImageUrl propriedade e atualizar o caminho para a imagem de forma adequada para que o aplicativo possa localizá-la.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>
Comentários
Essa classe define uma região de ponto de acesso retangular em um ImageMap controle.This class defines a rectangular hot spot region in an ImageMap control. Para definir a região do RectangleHotSpot objeto, defina a Left propriedade como o valor que representa a coordenada x do canto superior esquerdo da região retangular.To define the region of the RectangleHotSpot object, set the Left property to the value that represents the x-coordinate of the rectangular region's top left corner. Defina a Top propriedade para o valor que representa a coordenada y do canto superior esquerdo da região retangular.Set the Top property to the value that represents the y-coordinate of the rectangular region's top left corner. Defina a Right propriedade para o valor que representa a coordenada x do canto inferior direito da região retangular.Set the Right property to the value that represents the x-coordinate of the rectangular region's bottom right corner. Conjunto da Bottom propriedade para o valor que representa a coordenada y do canto inferior direito da região retangular.Set of the Bottom property to the value that represents the y-coordinate of the rectangular region's bottom right corner.
Quando um RectangleHotSpot controle é clicado, a página navega para uma URL, gera uma postagem de volta para o servidor ou não faz nada.When a RectangleHotSpot control is clicked, the page navigates to a URL, generates a post back to the server, or does nothing. A HotSpotMode propriedade especifica esse comportamento.The HotSpotMode property specifies this behavior. Para navegar até uma URL, defina a HotSpotMode propriedade como HotSpotMode.Navigate e use a NavigateUrl propriedade para especificar a URL para a qual navegar.To navigate to a URL, set the HotSpotMode property to HotSpotMode.Navigate and use the NavigateUrl property to specify the URL to navigate to. Para postar novamente no servidor, defina a HotSpotMode propriedade como HotSpotMode.PostBack e use a PostBackValue propriedade para especificar um nome para o RectangleHotSpot objeto.To post back to the server, set the HotSpotMode property to HotSpotMode.PostBack and use the PostBackValue property to specify a name for the RectangleHotSpot object. Esse nome será passado nos dados do ImageMapEventArgs evento quando o RectangleHotSpot for clicado.This name will be passed in the ImageMapEventArgs event data when the RectangleHotSpot is clicked. .. Se você quiser que o HotSpot objeto não tenha nenhum comportamento, defina a HotSpotMode propriedade como HotSpotMode.Inactive .If you want the HotSpot object to have no behavior, set the HotSpotMode property to HotSpotMode.Inactive.
Construtores
| RectangleHotSpot() |
Inicializa uma nova instância da classe RectangleHotSpot.Initializes a new instance of the RectangleHotSpot class. |
Propriedades
| AccessKey |
Obtém ou define a chave de acesso que permite navegar rapidamente para a região HotSpot.Gets or sets the access key that allows you to quickly navigate to the HotSpot region. (Herdado de HotSpot) |
| AlternateText |
Obtém ou define o texto alternativo a ser exibido para um objeto HotSpot em um controle ImageMap quando a imagem não está disponível ou é renderizada para um navegador que não dá suporte a imagens.Gets or sets the alternate text to display for a HotSpot object in an ImageMap control when the image is unavailable or renders to a browser that does not support images. (Herdado de HotSpot) |
| Bottom |
Obtém ou define a coordenada y do lado inferior da região retangular definida por este objeto RectangleHotSpot.Gets or sets the y-coordinate of the bottom side of the rectangular region defined by this RectangleHotSpot object. |
| HotSpotMode |
Obtém ou define o comportamento de um objeto HotSpot em um controle ImageMap quando se clica em HotSpot.Gets or sets the behavior of a HotSpot object in an ImageMap control when the HotSpot is clicked. (Herdado de HotSpot) |
| IsTrackingViewState |
Obtém um valor que indica se o objeto HotSpot está controlando suas alterações de estado de exibição.Gets a value indicating whether the HotSpot object is tracking its view-state changes. (Herdado de HotSpot) |
| Left |
Obtém ou define a coordenada x do lado esquerdo da região retangular definida por este objeto RectangleHotSpot.Gets or sets the x-coordinate of the left side of the rectangular region defined by this RectangleHotSpot object. |
| MarkupName |
Quando substituído em uma classe derivada, obtém a representação de cadeia de caracteres para a forma do objeto HotSpot.When overridden in a derived class, gets the string representation for the HotSpot object's shape. (Herdado de HotSpot) |
| NavigateUrl |
Obtém ou define a URL para navegar quando um objeto HotSpot é clicado.Gets or sets the URL to navigate to when a HotSpot object is clicked. (Herdado de HotSpot) |
| PostBackValue |
Obtém ou define o nome do objeto HotSpot a passar nos dados do evento quando o HotSpot é clicado.Gets or sets the name of the HotSpot object to pass in the event data when the HotSpot is clicked. (Herdado de HotSpot) |
| Right |
Obtém ou define a coordenada x do lado direito da região retangular definida por este objeto RectangleHotSpot.Gets or sets the x-coordinate of the right side of the rectangular region defined by this RectangleHotSpot object. |
| TabIndex |
Obtém ou define o índice de tabulação da região HotSpot.Gets or sets the tab index of the HotSpot region. (Herdado de HotSpot) |
| Target |
Obtém ou define a janela ou o quadro de destino no qual exibir o conteúdo da página da Web vinculada a quando um objeto HotSpot que navega para uma URL é clicado.Gets or sets the target window or frame in which to display the Web page content linked to when a HotSpot object that navigates to a URL is clicked. (Herdado de HotSpot) |
| Top |
Obtém ou define a coordenada y do lado superior da região retangular definida por este objeto RectangleHotSpot.Gets or sets the y-coordinate of the top side of the rectangular region defined by this RectangleHotSpot object. |
| ViewState |
Obtém um dicionário de informações de estado que permite salvar e restaurar o estado de exibição de um objeto HotSpot em várias solicitações da mesma página.Gets a dictionary of state information that allows you to save and restore the view state of a HotSpot object across multiple requests for the same page. (Herdado de HotSpot) |
Métodos
| Equals(Object) |
Determina se o objeto especificado é igual ao objeto atual.Determines whether the specified object is equal to the current object. (Herdado de Object) |
| GetCoordinates() |
Retorna uma cadeia de caracteres que representa as coordenadas x e y do canto superior esquerdo de um objeto RectangleHotSpot e as coordenadas x e y de seu canto inferior direito.Returns a string that represents the x -and y-coordinates of a RectangleHotSpot object's top left corner and the x- and y-coordinates of its bottom right corner. |
| GetHashCode() |
Serve como a função de hash padrão.Serves as the default hash function. (Herdado de Object) |
| GetType() |
Obtém o Type da instância atual.Gets the Type of the current instance. (Herdado de Object) |
| LoadViewState(Object) |
Restaura o estado de exibição salvo anteriormente do objeto HotSpot para o objeto.Restores the HotSpot object's previously saved view state to the object. (Herdado de HotSpot) |
| MemberwiseClone() |
Cria uma cópia superficial do Object atual.Creates a shallow copy of the current Object. (Herdado de Object) |
| SaveViewState() |
Salva as alterações ao estado de exibição do objeto HotSpot desde a hora em que a página foi postada de volta no servidor.Saves the changes to the HotSpot object's view state since the time the page was posted back to the server. (Herdado de HotSpot) |
| ToString() |
Retorna a representação String desta instância de um objeto HotSpot.Returns the String representation of this instance of a HotSpot object. (Herdado de HotSpot) |
| TrackViewState() |
Faz com que o objeto HotSpot controle alterações a seu estado de exibição para que eles possam ser armazenadas no objeto StateBag do objeto.Causes the HotSpot object to track changes to its view state so they can be stored in the object's StateBag object. Esse objeto é acessível por meio da propriedade ViewState.This object is accessible through the ViewState property. (Herdado de HotSpot) |
Implantações explícitas de interface
| IStateManager.IsTrackingViewState |
Obtém um valor que indica se o objeto HotSpot está controlando suas alterações de estado de exibição.Gets a value indicating whether the HotSpot object is tracking its view-state changes. (Herdado de HotSpot) |
| IStateManager.LoadViewState(Object) |
Restaura o estado de exibição salvo anteriormente do objeto HotSpot para o objeto.Restores the HotSpot object's previously saved view state to the object. (Herdado de HotSpot) |
| IStateManager.SaveViewState() |
Salva as alterações ao estado de exibição do objeto HotSpot desde a última vez em que a página foi postada de volta no servidor.Saves the changes to the HotSpot object's view state since the last time the page was posted back to the server. (Herdado de HotSpot) |
| IStateManager.TrackViewState() |
Instrui a região HotSpot a rastrear alterações para seu estado de exibição.Instructs the HotSpot region to track changes to its view state. (Herdado de HotSpot) |