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

Same content for all tooltips

1 Answer 107 Views
ToolTip
This is a migrated thread and some comments may be shown as answers.
khurram
Top achievements
Rank 1
khurram asked on 08 Aug 2008, 08:37 PM
Hi,

In one of our application's page we have a repeater which displays results and contains controls such as hyperlinks which display certain contents in a tooltip.

The content which is to be displayed in the tooltip is same for all the items of repeater and is in a user control. As its same, it doesnt really make sense to add multiple instances of this user control for each repeater item.

I tried with Tooltip manager as well which can have multiple target controls but its more suited to on load demands, and content being the same i dont want to make a request to the server every time when user clicks for tooltip.

What I am looking for is adding my tooltip content user control once in a page and then display it with multiple targets without calling server.

I am just wondering what would be the best way to do it.

Thanks in advance.

Regards,
Khurram

1 Answer, 1 is accepted

Sort by
0
Kevin Babcock
Top achievements
Rank 1
answered on 10 Aug 2008, 05:24 AM
Hello Khurram,

You can indeed use one RadToolTipManager on your page to show the same tooltip for multiple items in a Repeater control. However, since the items displayed in a Repeater are created dynamically, you will need to use the Repeater's OnItemDataBound event to dynamically add those items to the RadToolTipManager's TargetControls collection.

Here is a simple example:

<telerik:RadToolTipManager ID="RadToolTipManager1" runat="server" 
    Text="Hello, RadToolTip!"
</telerik:RadToolTipManager> 
 
<asp:Repeater ID="Repeater1" runat="server" 
    OnItemDataBound="Repeater1_ItemDataBound"
    <ItemTemplate> 
        <asp:Label ID="Label1" runat="server"  
            Text='<%# Eval("Name") %>'/> 
        <br /> 
    </ItemTemplate> 
</asp:Repeater> 

protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e) 
    if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item) 
    { 
        var label = e.Item.FindControl("Label1"as Label; 
        RadToolTipManager1.TargetControls.Add(label.ClientID, true); 
    } 

This method adds the tooltip to every item in the Repeater, and you will not have to make any trips to the server for the tooltip to be displayed.

I hope this was helpful. Please let me know if I can assist you further.

Sincerely,
Kevin Babcock
Tags
ToolTip
Asked by
khurram
Top achievements
Rank 1
Answers by
Kevin Babcock
Top achievements
Rank 1
Share this question
or