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

Change ToolTip's Target on the client

1 Answer 93 Views
ToolTip
This is a migrated thread and some comments may be shown as answers.
Kevin Warnke
Top achievements
Rank 1
Kevin Warnke asked on 16 Mar 2009, 03:26 AM
I have a tooltip that I would like to trigger from various elements on the page.

Is there a way for me to change the ToolTip's Target using Javascript so that the "element" positioning will cause the tooltip to move as other elements initiate the show?

Thanks,
Kevin

1 Answer, 1 is accepted

Sort by
0
Svetlina Anati
Telerik team
answered on 18 Mar 2009, 12:13 PM
Hello Kevin,

Yes, it is possible to change the RadToolTip's target element on the client - this can be done by using its set_targetControlID client-side method. For your convenience I prepared the following code sample:

 <form id="form1" runat="server">  
        <asp:ScriptManager ID="ScriptManager1" runat="server" /> 
 
        <script type="text/javascript">     
       function ChangeTargetControl()  
       {  
          var tooltip = $find("<%=RadToolTip1.ClientID %>");  
          tooltip.set_targetControlID("<%=link2.ClientID %>");  
       }   
        </script> 
 
        <telerik:RadToolTip ID="RadToolTip1" runat="server" Text="This is a test tooltip" 
            Skin="Vista" TargetControlID="link1" RelativeTo="Element">  
        </telerik:RadToolTip> 
        <asp:HyperLink ID="link1" runat="server">First target</asp:HyperLink> 
        <br /> 
        <br /> 
        <asp:HyperLink ID="link2" runat="server">Second target</asp:HyperLink> 
        <br /> 
        <br /> 
        <button onclick="ChangeTargetControl();return false;">  
            Change target</button> 
    </form> 

The two hyperlinks serve as target controls and the tooltip is declaratively associated with the first one. When you click the button, the second hyperlink becomes the target of the tooltip.


Regards,
Svetlina
the Telerik team


Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
ToolTip
Asked by
Kevin Warnke
Top achievements
Rank 1
Answers by
Svetlina Anati
Telerik team
Share this question
or