Same content for all tooltips

2 posts, 0 answers
  1. khurram
    khurram avatar
    13 posts
    Member since:
    May 2008

    Posted 08 Aug 2008 Link to this post


    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.

  2. Kevin Babcock
    Kevin Babcock avatar
    189 posts
    Member since:
    Mar 2007

    Posted 10 Aug 2008 Link to this post

    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:

    1 <telerik:RadToolTipManager ID="RadToolTipManager1" runat="server" 
    2     Text="Hello, RadToolTip!"
    3 </telerik:RadToolTipManager> 
    5 <asp:Repeater ID="Repeater1" runat="server" 
    6     OnItemDataBound="Repeater1_ItemDataBound"
    7     <ItemTemplate> 
    8         <asp:Label ID="Label1" runat="server"  
    9             Text='<%# Eval("Name") %>'/> 
    10         <br /> 
    11     </ItemTemplate> 
    12 </asp:Repeater> 

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

    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.

    Kevin Babcock
Back to Top