Alternative OverLibWrapper for displaying tooltips in ASP.NET

I looked at a good way to display tooltips dynamically, and I found OverLibWrapper that was exactly what I needed.

I have all the tooltip data stored in the section, tooltips are bound to their respective controls at the time Page_Load.

I did a quick test and worked great. The problem arose when I realized that OverLibWrapper did not work on master pages. Our site uses quite a few master pages, so their choice is not an option.

I was wondering if there is something like OverLibWrapper that I could use.

EDIT:

What I'm looking for is a control for displaying attractive tooltips when hovering over the mouse, preferably instantly resembling an overlay (I can't imagine anything because I just show the raw text) dynamically because the tooltip property in ASP.NET is not very beautiful and takes some time to appear. For example, let's say I have a set of messages:

class Message
{
    string ctrlid, msgtodisplay;
}

And when the page is loaded:

TooltipManager manager;
foreach(var m in messages)
{
    Tooltip tltp=new Tooltip;
    m.ControlID=m.ctrlid;
    m.Message=m.msgtodisplay;
    manager.AddTooltip(tltp);
}

This is basically what the Tooltip and TooltipManager functionality offers.

+3
source share
2 answers

Well, I finally solved my problem:

I used this function to find some kind of control (works with masterpages):

public static Control FindControlRecursive(Control root, string id)
{
    if (id == string.Empty)
        return null;

    if (root.ID == id)
        return root;

    foreach (Control c in root.Controls)
    {
        Control t = FindControlRecursive(c, id);
        if (t != null)
            return t;
    }
    return null;
}

And this method:

public static void load(Page page, string pageFileName)
{
    foreach (ConfiguracionElem elem in Configuracion.GetConfig(pageFileName).Tooltips)
    {
        WebControl ctrl = (WebControl)FindControlRecursive(page, elem.controlid);
        if (ctrl == null)
            throw new ControlNotFoundException("There no control'"+elem.controlid+"'")
        else
        {
            ctrl.Attributes.Add("onmouseover","return overlib('"+elem.message+"');");
            ctrl.Attributes.Add("onmouseout","return nd();");
        }
    }
}

Overlib script, ( ), javascript.

+1

:

NotesTooltip

, , .

, ? , .

+1

Source: https://habr.com/ru/post/1769410/


All Articles