3

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.

Gustavo Puma
  • 993
  • 12
  • 27

2 Answers2

1

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.

jimplode
  • 3,474
  • 3
  • 24
  • 42
  • Thanks for your answer, but I can't get the sample to work, after VS conversion it tells me some files are missing. I tried to make a new project but I get plenty of errors when trying to get the controls to work. – Gustavo Puma Oct 21 '10 at 01:30
  • I wouldn't really know how to. I'm kind of new to web programming. – Gustavo Puma Oct 22 '10 at 04:39
  • 1
    Give me your specifications, how you want to use it, and I will knock something simple up for you, to get you going. – jimplode Oct 22 '10 at 07:52
1

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.

Gustavo Puma
  • 993
  • 12
  • 27