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

DataList - ItemDatabound and TooltipManager

2 Answers 139 Views
ToolTip
This is a migrated thread and some comments may be shown as answers.
jc mag
Top achievements
Rank 1
jc mag asked on 25 Jan 2011, 09:41 PM
I've the following DataList:
<asp:DataList ID="dataListPhoto" runat="server" RepeatColumns="7" RepeatDirection="Horizontal" OnItemDataBound="dataListPhoto_ItemDataBound">
                <ItemTemplate>
                    <asp:Image ID="imgButton" runat="server" ImageUrl='<%# Eval("ImageUrl") %>' Width="32"
                        Height="32" userName='<%# Eval("User") %>' />
                </ItemTemplate>
            </asp:DataList>

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"  />
</telerik:RadToolTipManager>

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 Answers, 1 is accepted

Sort by
0
Svetlina Anati
Telerik team
answered on 27 Jan 2011, 03:45 PM
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 asp.net 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,
Svetlina
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.
0
jc mag
Top achievements
Rank 1
answered on 31 Jan 2011, 03:29 PM
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)
Tags
ToolTip
Asked by
jc mag
Top achievements
Rank 1
Answers by
Svetlina Anati
Telerik team
jc mag
Top achievements
Rank 1
Share this question
or