Telerik is a leading vendor of ASP.NET AJAX, ASP.NET MVC, Silverlight, WinForms and WPF controls and components, as well as .NET Reporting, .NET ORM , .NET CMS, Code Analysis, Mocking, Team Productivity and Automated Testing Tools. Building on its expertise in interface development and Microsoft technologies, Telerik helps customers build applications with unparalleled richness, responsiveness and interactivity. Telerik products help thousands of companies to be more productive and deliver reliable applications under budget and on time.
Version Q2 2011 released 07/12/2011
select

ToolTip / RadToolTip with ImageMap

FloorPlan

  • This example shows one way of using RadToolTip together with an image map.
    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.

Source Code

C# VB.NET
Show code in new window Demo isolation steps
  • <%@ Page Language="vb" AutoEventWireup="true" CodeFile="DefaultVB.aspx.vb" Inherits="Telerik.Web.Examples.ToolTip.UsingWithImageMap.DefaultVB" %>

    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
    <%@ Register TagPrefix="qsf" Namespace="Telerik.QuickStart" %>
    <%@ Register TagPrefix="qsf" TagName="Header" Src="~/Common/Header.ascx" %>
    <%@ Register TagPrefix="qsf" TagName="HeadTag" Src="~/Common/HeadTag.ascx" %>
    <%@ Register TagPrefix="qsf" TagName="Footer" Src="~/Common/Footer.ascx" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <qsf:HeadTag ID="Headtag1" runat="server" />
    </head>
    <body class="BODY">
        <form id="Form1" method="post" runat="server">
        <qsf:Header ID="Header1" runat="server" NavigationLanguage="VB" XhtmlCompliant="false" />
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        </telerik:RadScriptManager>
        <div style="text-align: center">
    <asp:ImageMap ID="ImageMap1" HotSpotMode="Navigate" ImageUrl="Img/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 Coordinates="301,34,490,34,490,151,301,149,301,34" />
                <asp:PolygonHotSpot Coordinates="301,149,301,204,347,204,350,225,470,225,470,152,301,149" />
                <asp:PolygonHotSpot Coordinates="350,226,360,289,469,289,469,226,350,226" />
            </asp:ImageMap>
        </div>
        <telerik:RadToolTip ID="tooltip" RelativeTo="Mouse" runat="server" TargetControlID="area0"
            Animation="FlyIn" Position="BottomCenter" IsClientID="true" ShowCallout="false"
            EnableShadow="true">
            <img src="Img/livingRoom.jpg" alt="LivingRoom" /></telerik:RadToolTip>
        <telerik:RadToolTip ID="RadToolTip1" RelativeTo="Mouse" runat="server" TargetControlID="area1"
            Animation="FlyIn" Position="TopRight" IsClientID="true" ShowCallout="false" EnableShadow="true">
            <img src="Img/kitchen.jpg" alt="Kitchen" /></telerik:RadToolTip>
        <telerik:RadToolTip ID="RadToolTip2" RelativeTo="Mouse" runat="server" TargetControlID="area2"
            Animation="FlyIn" Position="MiddleRight" IsClientID="true" ShowCallout="false"
            EnableShadow="true">
            <img src="Img/bathroom.jpg" alt="Bathroom" /></telerik:RadToolTip>
        <telerik:RadToolTip ID="RadToolTip3" RelativeTo="Mouse" runat="server" TargetControlID="area3"
            Animation="FlyIn" Position="BottomRight" IsClientID="true" ShowCallout="false"
            EnableShadow="true">
            <img src="Img/entrance.jpg" alt="Entrance" /></telerik:RadToolTip>
        <script type="text/javascript">
            //<![CDATA[
            var map = document.getElementsByName("ImageMapImageMap1")[0];
            var areas = map.getElementsByTagName("AREA");

            for (var i = 0; i < areas.length; i++) {
                var area = areas[i];
                area.setAttribute("id", "area" + i);
                //Prevent from postbacking the page
                area.onclick = function (e) { return false; };
            }
            //]]>
        </script>
        <qsf:Footer runat="server" ID="Footer1" />
        </form>
    </body>
    </html>

Get more than expected!

 
 

Take your time to truly experience the power of RadControls for ASP.NET AJAX with a free 60-day trial backed up by Telerik’s unlimited dedicated support.

Download your RadControls for ASP.NET AJAX trial and jumpstart your development with the available Getting Started resources.

If you have any questions, do not hesitate to contact us at sales@telerik.com.

Copyright 2002-2024 © Telerik. All right reserved
Telerik Inc, 201 Jones Rd, Waltham, MA 02451