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

Tooltip inside of Repeater Control?

3 Answers 223 Views
ToolTip
This is a migrated thread and some comments may be shown as answers.
Cole
Top achievements
Rank 1
Cole asked on 08 Aug 2008, 05:07 PM
Hi there,

I am new to the telerik controls and am seeking help in doing the following:

Scenario:  Using a repeater control to display images, and hoping to have the telerik tooltip apply a tooltip that will describe the image with some basic facts.

Example:
_____________________________________
| Name: Fun In The Sun                                      |
| Description: A picture of kids playing in the sun. |
--------------------------------------------------

How would I set this information dynamically into the tooltip and how would I reference the appropriate ID?

Any help is appreciated!

Thanks,
Rob


3 Answers, 1 is accepted

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

You can easily add controls to a RadToolTipManager control dynamically on the server. I just answered another post with a similar request and provided a simple example of how to do this using a Repeater control. You can check out that post here.

Also, there is a great example in our Demo pages which shows how to implement exactly what you are trying to do. You can check out that demo here.

I hope this has been helpful. Please let me know if you require further assistance.

Sincerely,
Kevin Babcock
0
Yevgeniya
Top achievements
Rank 2
answered on 19 Aug 2008, 11:44 PM
Hi Kevin,

Have you ever run into a problem with tooltips and nested repeaters? The first level of the repeater gets toolpified just fine, but the second level does not ... nothing happens when I click on the specified elements, even though I added them to the target controls of the RadToolTipManager.

By the way, what happens if you add the same target controls multiple times?

Thanks,

Yevgeniya
0
Tsvetie
Telerik team
answered on 21 Aug 2008, 08:48 AM
Hello Yevgeniya,
I just answered your ticket with the same question. I will give the information here as well, so that it is available to all, who might run into the same problem:

***
The problem is caused by the fact that you are not passing the correct ClientIDs to the RadToolTipManager, or rather you pass the correct ClientIDs and then change them. Have a look at the following code:
    protected void rpTopicRepeater_ItemCommand(object source, RepeaterCommandEventArgs e)  
    {  
        int topicID = 0;  
        try 
        {  
            topicID = Int32.Parse(((HtmlInputHidden)e.Item.FindControl("topicIdentifier")).Value);  
        }  
        catch { }  
        for (int i = 0; i < ((List<FrequentlyAskedQuestionTopic>)this.rpTopicRepeater.DataSource).Count; ++i)  
        {  
            if (((List<FrequentlyAskedQuestionTopic>)this.rpTopicRepeater.DataSource)[i].Identifier == topicID)  
            {  
                this.rpTopicFaqRepeater.DataSource = this.GetFaqsByTopic(((List<FrequentlyAskedQuestionTopic>)this.rpTopicRepeater.DataSource)[i].Identifier);  
                this.rpTopicFaqRepeater.DataBind();  
                break;  
            }  
        }  
        this.rpTopicFaqRepeater.Visible = true;  
        ((PlaceHolder)e.Item.FindControl("phTopicFaqs")).Controls.Add(this.rpTopicFaqRepeater);  
    } 

As you can see, first you add the ClientIDs of the items to the TargetControls collection (using the ItemDataBound event) and then you add the repeater to an INamingContainer (the parent repeater), which changes the those ClientIDs. At this point, the RadToolTipManager has the wrong ClientIDs. I just changed that function to the following and everything worked as expected:
    protected void rpTopicRepeater_ItemCommand(object source, RepeaterCommandEventArgs e)  
    {  
        int topicID = 0;  
        try 
        {  
            topicID = Int32.Parse(((HtmlInputHidden)e.Item.FindControl("topicIdentifier")).Value);  
        }  
        catch { }  
 
        this.rpTopicFaqRepeater.Visible = true;  
        ((PlaceHolder)e.Item.FindControl("phTopicFaqs")).Controls.Add(this.rpTopicFaqRepeater);  
 
        for (int i = 0; i < ((List<FrequentlyAskedQuestionTopic>)this.rpTopicRepeater.DataSource).Count; ++i)  
        {  
            if (((List<FrequentlyAskedQuestionTopic>)this.rpTopicRepeater.DataSource)[i].Identifier == topicID)  
            {  
                this.rpTopicFaqRepeater.DataSource = this.GetFaqsByTopic(((List<FrequentlyAskedQuestionTopic>)this.rpTopicRepeater.DataSource)[i].Identifier);  
                this.rpTopicFaqRepeater.DataBind();  
                break;  
            }  
        }  
    } 

***

As for your additional question - about adding the same ID to the TargetControls collection - this should not lead to unexpected behavior, but in general we do not recommend it.

Sincerely yours,
Tsvetie
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
ToolTip
Asked by
Cole
Top achievements
Rank 1
Answers by
Kevin Babcock
Top achievements
Rank 1
Yevgeniya
Top achievements
Rank 2
Tsvetie
Telerik team
Share this question
or