DataList - ItemDatabound and TooltipManager

3 posts, 0 answers
  1. jc mag
    jc mag avatar
    106 posts
    Member since:
    Aug 2005

    Posted 25 Jan 2011 Link to this post

    I've the following DataList:
    <asp:DataList ID="dataListPhoto" runat="server" RepeatColumns="7" RepeatDirection="Horizontal" OnItemDataBound="dataListPhoto_ItemDataBound">
                        <asp:Image ID="imgButton" runat="server" ImageUrl='<%# Eval("ImageUrl") %>' Width="32"
                            Height="32" userName='<%# Eval("User") %>' />

    And want to show a tooltip on each Image (imgButton):

    <telerik:RadToolTipManager ID="ttm" Height="200px" Width="350px" HideEvent="LeaveTargetAndToolTip"
        RelativeTo="Element" Position="TopCenter" runat="server" Skin="Telerik" EnableShadow="true"
        Animation="Fade" ShowDelay="1000">
        <WebServiceSettings Method="GetHoveringText" Path="LinkHoveringAuthor.asmx"  />

    In my code-behind I try to add each Images to RadToolTipManager's TargetCollections:

    protected void dataListPhoto_ItemDataBound(object sender, DataListItemEventArgs e)
            Image c = (Image) e.Item.FindControl("imgButton");
            string value = c.Attributes["userName"];
            ttm.TargetControls.Add(c.UniqueID, value, false);

    But the Tooltip is only displayed for the first Image....

    2nd question: in my LinkHoveringAuthor.GetHoveringText method I try retrieve the userName:
    var contextDictionary = (IDictionary<string, object>)context;
                if (contextDictionary["Value"] != null)
                    string name = contextDictionary["Value"].ToString();

    It works, but backslashes are omitted... :-|
    For example, here:
    ttm.TargetControls.Add(c.UniqueID, value, false); 
    if value="dom\user", in the webmethod, the "name" variable equals to "domuser"...
  2. Svetlina Anati
    Svetlina Anati avatar
    2795 posts

    Posted 27 Jan 2011 Link to this post

    Hi jc mag,

     Straight to your questions:

    1) I was not able to reproduce the issue with the first item tooltipified only - please examine the attached demo which I prepared for you.

    2) The "\" sign is a special sign and thus it would break the functionality once the content is returned - that is why the RadToolTipManager encodes it. However, you can manipulate the string e.g by replacing special signs with allowed signs when needed and vice versa - this is a standard approach e,g when dealing with databases.

    For your convenience and reference I also demonstrated 2) in my demo, please use it as a start point and let me know how it goes.

    Best wishes,
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  3. jc mag
    jc mag avatar
    106 posts
    Member since:
    Aug 2005

    Posted 31 Jan 2011 Link to this post

    Thanks, all works now :)
    (for the 1st problem, I had a RadAjaxPanel encapsulating the whole page, except the RadTooltipManager, so I think its TargetControls was not updated on ajax requests)
Back to Top