Tooltip inside of Repeater Control?

4 posts, 0 answers
  1. Cole
    Cole avatar
    5 posts
    Member since:
    Aug 2008

    Posted 08 Aug 2008 Link to this post

    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


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

    Posted 10 Aug 2008 Link to this post

    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Yevgeniya
    Yevgeniya avatar
    15 posts
    Member since:
    Mar 2008

    Posted 19 Aug 2008 Link to this post

    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
  5. Tsvetie
    Admin
    Tsvetie avatar
    1517 posts

    Posted 21 Aug 2008 Link to this post

    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.
Back to Top