Example of Tooltip Menu in ASP.NET MVC Tooltip Control
In this demo, the Tooltip has been customized to show the list of menu items.
- WI-FI
- Bluetooth
- SIM cards
- Display
- Sound
- Battery
- Users
- Location
- Security
- Language
@Html.UiToolbar(new UiToolbarOptions { Id = "Toolbar", Items = (List<UiToolbarItem>)ViewData["popupItems"] })
@Html.UiTooltip(new UiTooltipOptions { Id = "tooltip", Target = "#Toolbar [data-id]", Content = "Settings", Width = "170px", Position = UiTooltipPosition.BottomCenter, OpensOn = UiTooltipOpensOn.Click, CssClass = "e-settings", OnBeforeOpen = "onBeforeRender" })
<style>
.control-section { padding: 10px 15px; }
.property-row { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 8px 0; }
.toolbarContainer { max-width: 400px; margin: 40px auto; }
.settings-list { list-style: none; margin: 0; padding: 0; }
.settings-list li { padding: 6px 4px; }
</style>
<template id="tipWireless"><ul class="settings-list"><li>WI-FI</li><li>Bluetooth</li><li>SIM cards</li></ul></template>
<template id="tipDevice"><ul class="settings-list"><li>Display</li><li>Sound</li><li>Battery</li><li>Users</li></ul></template>
<template id="tipPersonal"><ul class="settings-list"><li>Location</li><li>Security</li><li>Language</li></ul></template>
<div class="control-section">
<div id="Tooltip">
<div class="toolbarContainer">
@Html.UiToolbar(new UiToolbarOptions { Id = "Toolbar", Items = (List<UiToolbarItem>)ViewData["popupItems"] })
</div>
</div>
@Html.UiTooltip(new UiTooltipOptions { Id = "tooltip", Target = "#Toolbar [data-id]", Content = "Settings", Width = "170px", Position = UiTooltipPosition.BottomCenter, OpensOn = UiTooltipOpensOn.Click, CssClass = "e-settings", OnBeforeOpen = "onBeforeRender" })
</div>
<script>
// Syncfusion: beforeRender fills the Tooltip with the settings of the group of the item that was clicked
function onBeforeRender(args) {
var item = args.target.closest('.ui-tb-btn');
var name = item ? item.getAttribute('data-id') : '';
if (['Wireless', 'Device', 'Personal'].indexOf(name) >= 0) { args.template = '#tip' + name; }
}
</script>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using Lumen.UI.Mvc;
namespace YourApp.Controllers
{
public class TooltipController : Controller
{
// The page is Views/Tooltip/Menu.cshtml; it draws what ViewData holds.
public ActionResult Menu()
{
ViewData["popupItems"] = new List<UiToolbarItem>
{
new UiToolbarItem { Id = "Wireless", Text = "Wireless", IconCss = "e-icons e-copy", TooltipText = "Wireless" },
new UiToolbarItem { Id = "Device", Text = "Device", IconCss = "e-icons e-copy", TooltipText = "Device" },
new UiToolbarItem { Id = "Personal", Text = "Personal", IconCss = "e-icons e-copy", TooltipText = "Personal" }
};
return View();
}
}
}
@* Install once: Install-Package Lumen.UI.Mvc (or: dotnet add package Lumen.UI.Mvc) *@
@* Views/Web.config: <add namespace="Lumen.UI.Mvc" /> *@
@* Views/Shared/_Layout.cshtml *@
<head>
@Html.UiStyles()
<link rel="stylesheet" href="~/Content/site.css" />
</head>
<body>
@RenderBody()
@Html.UiScripts()
@RenderSection("scripts", required: false)
</body>
Tooltip has been integrated with tooltipMenu-list component to display the Tooltip menu. With the help of BeforeRender event, dataSource for tooltipMenu-list changed and its instance assigned to Content of Tooltip to appear like menu. On clicking the Toolbar items, the corresponding Tooltip menu will be opened.