Tooltip HtmlHelper Overview

The Telerik UI Tooltip HtmlHelper for ASP.NET MVC is a server-side wrapper for the Kendo UI Tooltip widget.

The Tooltip displays a popup hint for a specified HTML element. Its content can be defined either as static text or loaded dynamically with AJAX.

Basic Configuration

  1. Make sure you followed all the steps from the introductory article on Telerik UI for ASP.NET MVC.
  2. Create a new action method.

    public ActionResult Index()
    {
        return View();
    }
    
  3. Add a Tooltip.

        <%: Html.Kendo().Tooltip()
            .For("#container") // The for option of the Tooltip is mandatory.
                            // It is a jQuery selector which specifies the element or the container for the elements for which the Tooltip will be shown.
            .Filter("a[title]") // The jQuery selector which narrows the elements within the container for which the Tooltip will be shown.
            .Content("custom text")
        %>
    
        @(Html.Kendo().Tooltip()
            .For("#container") // The for option of the Tooltip is mandatory.
                            // It is a jQuery selector which specifies the element or the container for the elements for which the Tooltip will be shown.
            .Filter("a[title]") // The jQuery selector which narrows the elements within the container for which the Tooltip will be shown.
            .Content("custom text")
        )
    

Functionality and Features

The Tooltip provides options for configuring its content.

Events

You can subscribe to all Tooltip events. For a complete example on basic Tooltip events, refer to the demo on using the events of the Tooltip.

Handling by Handler Name

The following example demonstrates how to subscribe to events by a handler name.

    <%: Html.Kendo().Tooltip()
        .For("#container")
        .Events(e => e
            .Show("tooltip_show")
            .Hide("tooltip_hide")
        )
    %>
    <script>
        function tooltip_show() {
            // Handle the show event.
        }

        function tooltip_hide() {
            // Handle the hide event.
        }
    </script>
    @(Html.Kendo().Tooltip()
        .For("#container")
        .Events(e => e
            .Show("tooltip_show")
            .Hide("tooltip_hide")
        )
    )
    <script>
        function tooltip_show() {
            // Handle the show event.
        }

        function tooltip_hide() {
            // Handle the hide event.
        }
    </script>

Handling by Template Delegate

The following example demonstrates how to subscribe to events by a template delegate.

@(Html.Kendo().Tooltip()
    .For("#container")
    .Events(e => e
        .Show(@<text>
        function() {
            // Handle the show event inline.
        }
        </text>)
        .Hide(@<text>
        function() {
            // Handle the hide event inline.
        }
        </text>)
    )
)

Referencing Existing Instances

To reference an existing Tooltip instance, use the jQuery.data() configuration option. Once a reference is established, use the Tooltip client-side API to control its behavior.

// Place the following after the Tooltip for ASP.NET MVC declaration.
<script>
    $(function() {
        // The For() of the Tooltip is used to get its client-side instance.
        var tooltip = $("#container").data("kendoTooltip");
    });
</script>

See Also

In this article
Not finding the help you need? Improve this article