This is a migrated thread and some comments may be shown as answers.

RadTooltip Not Formatting HTML for Treeview Node Image

2 Answers 146 Views
ToolTip
This is a migrated thread and some comments may be shown as answers.
Scott
Top achievements
Rank 1
Scott asked on 14 Sep 2009, 04:59 PM
I am adding a RadTreeNode to a RadTooltipManager so that I can display formatted HTML text in the tooltip when someone hovers over the node.  This works fine as long as someone hovers over the node text.  But the RadToolTip doesn't display whenever someone hovers over the node image - instead it just displays a standard tooltip which does not format the HTML. 
Any ideas on how to get the RadToolTip to display formatted HTML when someone hovers over the image would be greatly appreciated.

 

        protected void Button1_Click(object sender, EventArgs e)
        {
           RadTreeNode tn1 = new RadTreeNode();
           tn1.ImageUrl = @"~\images\customer.PNG";
           tn1.Text = "test node";
           string htmlStr = @"<html>test1<br/>test2</html>";
           tn1.ToolTip = htmlStr;
           tn1.AllowDrop = false;
           tn1.Attributes["id"] = Guid.NewGuid().ToString();
           RadToolTipManager1.TargetControls.Add(tn1.Attributes["id"], true);
           RadTreeView1.Nodes.Add(tn1);
        }

 


Thanks,
Scott

2 Answers, 1 is accepted

Sort by
0
Svetlina Anati
Telerik team
answered on 17 Sep 2009, 09:22 AM
Hello Scott,

Thank you for the provided code, I examined it and I was able to reproduce the described behavior. This si teh exected behavior in such configuration if you examine the rendered HTML for the node. When you have set the ImageUrl property, the node is rendered as an IMG element which holds the image and a SPAN element which holds the text. However, when you add the ID attribute to the node, it is added as an attribute to the SPAN element and thus as a result you have only the SPAN added and tooltipified by the manager. What I can suggest is to use an ItemTemplate and put your own image there - in this manner you will be able to manipulate it on the server. If you use this approach you can even simply put a separate tooltip in the ItemTemplate instead of taking care for teh TargetControls collection, if this meets your requirements.

I hoep that my explanation and suggest are helpful, let me know how it goes.

Sincerely yours,
Svetlina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Scott
Top achievements
Rank 1
answered on 17 Sep 2009, 06:48 PM
Thanks for your help Svetlina.  I added both the image and text for the node in a nodetemplate and it works perfectly.

        <telerik:RadTreeView ID="RadTreeView1" Runat="server">
            <NodeTemplate>
            <img src="Images/home.png" alt=""/>
            <asp:Label ID="lblText" runat="server"><%# DataBinder.Eval(Container, "Text") %></asp:Label>
            </NodeTemplate>
            <Nodes>
                <telerik:RadTreeNode runat="server" Text="Root RadTreeNode1">
                </telerik:RadTreeNode>
            </Nodes>
        </telerik:RadTreeView>

   
Tags
ToolTip
Asked by
Scott
Top achievements
Rank 1
Answers by
Svetlina Anati
Telerik team
Scott
Top achievements
Rank 1
Share this question
or