New to Telerik UI for ASP.NET AJAX? Download free 30-day trial

RadToolTip with ImageMap

FloorPlan

Often there is a need to display additional infomration when the user hovers over image map regions. This can be acomplished with RadToolTip in order to provide richer experience for the users - with RadToolTip you can show any kind of content - images, pages, user controls, etc. There are several matters to be considered in this case:

  1. Such behavior cannot be achieved without additional JavaScript. This is needed because the asp:ImageMap control itself does not provide IDs for the hotspots and RadToolTip / RadToolTipManager needs an ID to which it can attach.
  2. If your asp:ImageMap control has the HotSpotMode property set to Navigate, you will need to make sure that the postback, that would occur when clicking on area, is cancelled.

Please, note that the image map renders content which is not XHTML compliant (due to the way the ID is formed and also the name attribute of the map) - that is why the demo will not successfully pass validation and the RadToolTip control is not the reason for it but the standard image map.

Note: Since the target areas are not real separate elements, the tooltip should be configured to be relative to the mouse.

  • DefaultVB.aspx
  • scripts.js
  • styles.css
<%@ Page Language="vb"  %>

<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head runat="server">
    <title>Telerik ASP.NET Example</title>
    <link href="styles.css" rel="stylesheet" />
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager runat="server" ID="RadScriptManager1" />
    <telerik:RadSkinManager ID="RadSkinManager1" runat="server" ShowChooser="true" />
    <div class="demo-container size-narrow no-bg">
        <asp:ImageMap ID="ImageMap1" HotSpotMode="Navigate" ImageUrl="images/FloorPlan.jpg"
            AlternateText="FloorPlan" runat="server">
            <asp:PolygonHotSpot Coordinates="36,221,36,304,134,304,134,278,228,278,228,304,359,304,359,279,349,228,346,205,301,205,301,34,36,34,36,221">
            </asp:PolygonHotSpot>
            <asp:PolygonHotSpot Coordinates="301,34,490,34,490,151,301,149,301,34"></asp:PolygonHotSpot>
            <asp:PolygonHotSpot Coordinates="301,149,301,204,347,204,350,225,470,225,470,152,301,149">
            </asp:PolygonHotSpot>
            <asp:PolygonHotSpot Coordinates="350,226,360,289,469,289,469,226,350,226"></asp:PolygonHotSpot>
        </asp:ImageMap>
    </div>
    <telerik:RadToolTip RenderMode="Lightweight" ID="tooltip" RelativeTo="Mouse" runat="server" TargetControlID="area0"
        Animation="FlyIn" Position="BottomCenter" IsClientID="true" ShowCallout="false" RenderInPageRoot="true">
        <img src="images/livingRoom.jpg" alt="LivingRoom" /></telerik:RadToolTip>
    <telerik:RadToolTip RenderMode="Lightweight" ID="RadToolTip1" RelativeTo="Mouse" runat="server" TargetControlID="area1"
        Animation="FlyIn" Position="TopRight" IsClientID="true" ShowCallout="false" RenderInPageRoot="true">
        <img src="images/kitchen.jpg" alt="Kitchen" /></telerik:RadToolTip>
    <telerik:RadToolTip RenderMode="Lightweight" ID="RadToolTip2" RelativeTo="Mouse" runat="server" TargetControlID="area2"
        Animation="FlyIn" Position="MiddleRight" IsClientID="true" ShowCallout="false" RenderInPageRoot="true">
        <img src="images/bathroom.jpg" alt="Bathroom" /></telerik:RadToolTip>
    <telerik:RadToolTip RenderMode="Lightweight" ID="RadToolTip3" RelativeTo="Mouse" runat="server" TargetControlID="area3"
        Animation="FlyIn" Position="BottomRight" IsClientID="true" ShowCallout="false" RenderInPageRoot="true">
        <img src="images/entrance.jpg" alt="Entrance" /></telerik:RadToolTip>
    <script src="scripts.js" type="text/javascript"></script>
    <script type="text/javascript">
        //<![CDATA[
        serverID("imageMapID", "<%= ImageMap1.ClientID %>");
        //]]> 
    </script>
    </form>
</body>
</html>

Support & Learning Resources

Find Assistance