Question

I looked into a nice way to display tooltips dynamically and I found OverLibWrapper, which was exactly what I needed.

I have all the tooltip data stored in a custom configuration section, the tooltips are bound to their respective controls during Page_Load.

I did a quick test and worked fine. The problem came up when I realized that OverLibWrapper didn't work on masterpages. Our website has uses quite a few masterpages, so taking them out isn't an option.

I was wondering if there's anything like OverLibWrapper that I could use.

EDIT:

What I'm looking for is a control to display good-looking tooltips on mouseover preferably instantly like overlib (nothing fancy because I'm just displaying raw text) in a dynamic way, because the tooltip property in ASP.NET is not very pretty and takes a while to appear. For example let's say I have a collection 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);
}

So basically something that offers the functionality of Tooltip and TooltipManager.

Was it helpful?

Solution 2

Well I finally solved my problem:

I've used this function to find any 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's no control'"+elem.controlid+"'")
        else
        {
            ctrl.Attributes.Add("onmouseover","return overlib('"+elem.message+"');");
            ctrl.Attributes.Add("onmouseout","return nd();");
        }
    }
}

I added the Overlib library manually to a script folder, then I iterated through my Custom Configuration Section (where my tooltip data is stored) to add the javascript attributes dynamically.

OTHER TIPS

Take a look at this:

NotesTooltip

I think this will do what you need.

Have you thought about just writing your own? Sometimes I find the things out there by other people are never quite fit for my needs.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top