Partager via


ImageMap Web Server Control Declarative Syntax 

Creates a control that displays an image on a page. When a hot spot region that is defined within the ImageMap control is clicked, the control either generates a postback to the server or navigates to a specified URL.

<asp:ImageMap
    AccessKey="string"
    AlternateText="string"
    BackColor="color name|#dddddd"
    BorderColor="color name|#dddddd"
    BorderStyle="NotSet|None|Dotted|Dashed|Solid|Double|Groove|Ridge|
        Inset|Outset"
    BorderWidth="size"
    CssClass="string"
    DescriptionUrl="uri"
    Enabled="True|False"
    EnableTheming="True|False"
    EnableViewState="True|False"
    ForeColor="color name|#dddddd"
    GenerateEmptyAlternateText="True|False"
    Height="size"
    HotSpotMode="NotSet|Navigate|PostBack|Inactive"
    ID="string"
    ImageAlign="NotSet|Left|Right|Baseline|Top|Middle|Bottom|
        AbsBottom|AbsMiddle|TextTop"
    ImageUrl="uri"
    OnClick="Click event handler"
    OnDataBinding="DataBinding event handler"
    OnDisposed="Disposed event handler"
    OnInit="Init event handler"
    OnLoad="Load event handler"
    OnPreRender="PreRender event handler"
    OnUnload="Unload event handler"
    runat="server"
    SkinID="string"
    Style="string"
    TabIndex="integer"
    Target="string"
    ToolTip="string"
    Visible="True|False"
    Width="size"
>
            <asp:CircleHotSpot
                AccessKey="string"
                AlternateText="string"
                HotSpotMode="NotSet|Navigate|PostBack|Inactive"
                NavigateUrl="uri"
                PostBackValue="string"
                Radius="integer"
                TabIndex="integer"
                Target="string|_blank|_parent|_search|_self|_top"
                X="integer"
                Y="integer"
            />
            <asp:PolygonHotSpot
                AccessKey="string"
                AlternateText="string"
                Coordinates="string"
                HotSpotMode="NotSet|Navigate|PostBack|Inactive"
                NavigateUrl="uri"
                PostBackValue="string"
                TabIndex="integer"
                Target="string|_blank|_parent|_search|_self|_top"
            />
            <asp:RectangleHotSpot
                AccessKey="string"
                AlternateText="string"
                Bottom="integer"
                HotSpotMode="NotSet|Navigate|PostBack|Inactive"
                Left="integer"
                NavigateUrl="uri"
                PostBackValue="string"
                Right="integer"
                TabIndex="integer"
                Target="string|_blank|_parent|_search|_self|_top"
                Top="integer"
            />
</asp:ImageMap>

Remarks

Use the ImageMap control to create an image that contains defined hot spot regions. When a user clicks a hot spot region, the control can either generate a postback to the server or navigate to a specified URL.

For more information on using the ImageMap control, see ImageMap Web Server Control.

The Image control can be a serviceable alternative if you only need to capture the coordinates where the user clicked, and do not require the hot spot capabilities.

Example

The following code example demonstrates how to create an ImageMap control declaratively that contains two CircleHotSpot objects. The System.Web.UI.WebControls.HotSpot.HotSpotMode property is set to HotSpotMode.Navigate, which causes the page to navigate to the specified URL each time a user clicks one of the circle hot spot regions. 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">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="head1" runat="server">
  <title>ImageMap Class Navigate Example</title>
</head>
  <body>
    <form id="form1" runat="server">
    
      <h3>ImageMap Class Navigate Example</h3>
      
      <h4>Shopping Choices:</h4>
      
       <asp:imagemap id="Shop"           
        imageurl="Images/ShopChoice.jpg"
        alternatetext="Shopping choices" 
        runat="Server">    
        
        <asp:circlehotspot
          navigateurl="http://www.tailspintoys.com"
          x="145"
          y="120"
          radius="75"
          hotspotmode="Navigate"
          alternatetext="Shop for toys">           
        </asp:circlehotspot> 
        
        <asp:circlehotspot
          navigateurl="http://www.cohowinery.com"
          x="145"
          y="290"
          radius="75"
          hotspotmode="Navigate"
          alternatetext="Shop for wine">
        </asp:circlehotspot>     
          
      </asp:imagemap>                 
                 
    </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">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="head1" runat="server">
  <title>ImageMap Class Navigate Example</title>
</head>
  <body>
    <form id="form1" runat="server">
    
      <h3>ImageMap Class Navigate Example</h3>
      
      <h4>Shopping Choices:</h4>
      
      <asp:imagemap id="Shop"           
        imageurl="Images/ShopChoice.jpg"
        width="150" 
        height="360"
        alternatetext="Shopping choices" 
        runat="Server">    
        
        <asp:circlehotspot
          navigateurl="http://www.tailspintoys.com"
          x="75"
          y="290"
          radius="75"
          hotspotmode="Navigate"
          alternatetext="Shop for toys">           
        </asp:circlehotspot> 
        
        <asp:circlehotspot
          navigateurl="http://www.cohowinery.com"
          x="75"
          y="120"
          radius="75"
          hotspotmode="Navigate"
          alternatetext="Shop for wine">
        </asp:circlehotspot>     
          
      </asp:imagemap>                 
                 
    </form>      
  </body>
</html>

See Also

Reference

ImageMap

Other Resources

ImageMap Web Server Control