Telerik is a leading vendor of ASP.NET AJAX, ASP.NET MVC, Silverlight, WinForms and WPF controls and components, as well as .NET Reporting, .NET ORM , .NET CMS, Code Analysis, Mocking, Team Productivity and Automated Testing Tools. Building on its expertise in interface development and Microsoft technologies, Telerik helps customers build applications with unparalleled richness, responsiveness and interactivity. Telerik products help thousands of companies to be more productive and deliver reliable applications under budget and on time.
Version Q1 2012 released 04/11/2012
select

ToolTip / Bind to Target

Setting TargetControlID for a RadToolTip (click inside the TextBox to show the RadToolTip):

 

Setting TargetControlID for a RadToolTip inside ItemTemplate of a RadGrid column (hover on the labels in the CategoryName column to show the RadToolTip):
CategoryIDCategoryName
1 Beverages
2 Condiments
3 Confections
4 Dairy Products
5 Grains/Cereals
6 Meat/Poultry
7 Produce
8 Seafood

 

Setting TargetControlID for a RadToolTip inside UserControl (click inside the TextBoxes to show the RadToolTips):
Name
Company
E-mail
Position
Address



  • TargetControlID property


    This example demonstrates three of the most common scenarios when the TargetControlID of the RadToolTip control is useful - the following ones:

    1. You have a control, that is a direct child of the form and you want to show a RadToolTip for it.
    2. You have a control in an ItemTemplate of a RadGrid column and you want to show a RadToolTip for it.
    3. You have a control in a UserControl and you want to show a RadToolTip for it.
    In all three scenarios, you just need to set the TargetControlID property of the RadToolTip to the ID of the control, you want to tooltipify.

Source Code

C# VB.NET
Show code in new window Demo isolation steps
  • <%@ Page Language="c#" %>

    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
    <%@ Register Src="ToolTipUserControl.ascx" TagName="ToolTipUserControl" TagPrefix="uc1" %>
    <%@ Register TagPrefix="qsf" Namespace="Telerik.QuickStart" %>
    <%@ Register TagPrefix="qsf" TagName="Header" Src="~/Common/Header.ascx" %>
    <%@ Register TagPrefix="qsf" TagName="HeadTag" Src="~/Common/HeadTag.ascx" %>
    <%@ Register TagPrefix="qsf" TagName="Footer" Src="~/Common/Footer.ascx" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <qsf:HeadTag ID="Headtag1" runat="server" />
    </head>
    <body class="BODY">
        <form id="Form1" method="post" runat="server">
        <qsf:Header ID="Header1" runat="server" NavigationLanguage="c#" />
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        </telerik:RadScriptManager>
        <table style="font-size: 11px;">
            <tr>
                <td>
                        <div class="bigModule" style="margin-bottom: 40px">
                            <div class="bigModuleBottom">
                                Setting TargetControlID for a RadToolTip (click inside the TextBox to show the RadToolTip):
                            </div>
                        </div>
                    <asp:TextBox ID="TextBox1" runat="server" Text="Show RadToolTip"></asp:TextBox>
                    <telerik:RadToolTip ID="RadToolTip1" runat="server" TargetControlID="TextBox1" ShowEvent="OnClick"
                        Position="MiddleRight" RelativeTo="Element" >
                        RadToolTip
                    </telerik:RadToolTip>
                </td>
            </tr>
            <tr>
                <td>
                    <p>
                        &nbsp;</p>
                        <div class="bigModule" style="margin-bottom: 40px">
                            <div class="bigModuleBottom">
                                Setting TargetControlID for a RadToolTip inside ItemTemplate of a RadGrid column
                                (hover on the labels in the CategoryName column to show the RadToolTip):
                            </div>
                        </div>
                    <telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="SqlDataSource1" GridLines="None"
                        Width="300px">
                        <GroupPanel ID="GroupPanel" Style="width: 100%;">
                        </GroupPanel>
                        <MasterTableView AutoGenerateColumns="False" DataKeyNames="CategoryID" DataSourceID="SqlDataSource1">
                            <RowIndicatorColumn Visible="False">
                                <HeaderStyle Width="20px" />
                            </RowIndicatorColumn>
                            <ExpandCollapseColumn Resizable="False" Visible="False">
                                <HeaderStyle Width="20px" />
                            </ExpandCollapseColumn>
                            <Columns>
                                <telerik:GridBoundColumn DataField="CategoryID" DataType="System.Int32" HeaderText="CategoryID"
                                    ReadOnly="True" SortExpression="CategoryID" UniqueName="CategoryID">
                                </telerik:GridBoundColumn>
                                <telerik:GridTemplateColumn DataField="CategoryName" HeaderText="CategoryName" SortExpression="CategoryName"
                                    UniqueName="CategoryName">
                                    <EditItemTemplate>
                                        <asp:TextBox ID="TextBox2" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.CategoryName") %>'></asp:TextBox>
                                    </EditItemTemplate>
                                    <ItemTemplate>
                                        <asp:Label ID="Label1" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.CategoryName") %>'>
                                        </asp:Label>
                                        <telerik:RadToolTip ID="RadToolTip1" runat="server" TargetControlID="Label1" Width="150px"
                                            RelativeTo="Element" Position="MiddleRight" >
                                            <%# DataBinder.Eval(Container, "DataItem.Description") %>
                                        </telerik:RadToolTip>
                                    </ItemTemplate>
                                </telerik:GridTemplateColumn>
                            </Columns>
                            <EditFormSettings>
                                <PopUpSettings ScrollBars="None" />
                            </EditFormSettings>
                        </MasterTableView>
                    </telerik:RadGrid>
                    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
                        ProviderName="System.Data.SqlClient" SelectCommand="SELECT [CategoryID], [CategoryName], [Description] FROM [Categories]">
                    </asp:SqlDataSource>
                </td>
            </tr>
            <tr>
                <td style="vertical-align: top;">
                    <p>
                        &nbsp;</p>
                        <div class="bigModule" style="margin-bottom: 40px">
                            <div class="bigModuleBottom">
                                Setting TargetControlID for a RadToolTip inside UserControl (click inside the TextBoxes
                                to show the RadToolTips):
                            </div>
                        </div>
                    <div style="width: 350px; height: 300px; padding: 10px 0px 0px 43px;">
                        <table style="font-size: 11px;">
                            <tr>
                                <td>
                                    <uc1:ToolTipUserControl ID="ToolTipUserControl6" Text="Name" Description="Please, fill in first name, familiy name and any other initials or titles."
                                        runat="server" />
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <uc1:ToolTipUserControl ID="ToolTipUserControl1" Text="Company" Description="Company name should be spelled out with proper capitalization."
                                        runat="server" />
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <uc1:ToolTipUserControl ID="ToolTipUserControl2" Text="E-mail" Description="It is possible to list more than one email, separated by comma."
                                        runat="server" />
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <uc1:ToolTipUserControl ID="ToolTipUserControl3" Text="Position" Description="Please list current position, followed by previous positions at the company, separated by commas."
                                        runat="server" />
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <uc1:ToolTipUserControl ID="ToolTipUserControl4" Text="Address" Description="Your current snail mail adrress."
                                        runat="server" />
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <br />
                                    <br />
                                    <asp:Button ID="btnSubmit" Text="Submit" runat="server" CssClass="button" Style="width: 100px;" />
                                </td>
                            </tr>
                        </table>
                    </div>
                </td>
            </tr>
        </table>
        <qsf:Footer runat="server" ID="Footer1" />
        </form>
    </body>
    </html>

Get more than expected!

Take your time to truly experience the power of RadControls for ASP.NET AJAX with a free 60-day trial backed up by Telerik’s unlimited dedicated support.

Download your RadControls for ASP.NET AJAX trial and jumpstart your development with the available Getting Started resources.

If you have any questions, do not hesitate to contact us at sales@telerik.com.

Copyright 2002-2012 © Telerik. All right reserved
Telerik Inc, 201 Jones Rd, Waltham, MA 02451