Show tooltip from Code.

3 posts, 1 answers
  1. Michael
    Michael avatar
    6 posts
    Member since:
    May 2014

    Posted 13 Nov 2014 Link to this post

    Hello there.

    I am still very new to telerik and most code in general, ive been wanting to use the tooltip as a information box. So lets say the user presses a button and submits their data, i want to - in the button event, be able to call the tooltip and show it including a label which i also set the text to from the button press.

    So far all ive got is this:
    <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />

    protected void Button1_Click(object sender, EventArgs e) {    LabelStatus.Text = "Tooltiptext";     
    // Show tooltip<br>    }

    <telerik:RadToolTipManager ID="RadToolTipManager1" runat="server" AnimationDuration="300" Width="400px" Height="80px" Animation="Slide" RelativeTo="BrowserWindow" Position="TopCenter" ShowEvent="FromCode" OnAjaxUpdate="OnAjaxUpdate" ShowCallout="true" >
          <telerik:ToolTipTargetControl TargetControlID=
    "LabelStatus" Value="LabelStatus" />

    I know the target is properly wrong, but ive run to a complete standstill and i hope that someone here can assist me in getting to where i wanna be.

    kind regards.
  2. Michael
    Michael avatar
    6 posts
    Member since:
    May 2014

    Posted 14 Nov 2014 in reply to Michael Link to this post

    i figured it out.

    RadToolTip / Manager.Show();

  3. Answer
    Marin Bratanov
    Marin Bratanov avatar
    5112 posts

    Posted 14 Nov 2014 Link to this post

    Hello Michael,

    I am glad you have found a workaround, but I can also suggest another approach - using the client-side API of the tooltip manager to show a tooltip for a specific control: You can also register the function call from the code-behind, should you need to:

    Another thing you can consider is whether you actually need to use a RadToolTipManager. If you only need rather simple content for a single label, it is easier to avoid a secondary request. For example:

    <asp:Button ID="Button1" Text="text" runat="server" OnClick="Button1_Click" />
    <asp:Label ID="Label1" Text="some label" runat="server" />
    <telerik:RadToolTip ID="RadToolTip1" runat="server" TargetControlID="Label1" Width="200px" Height="200px" Position="BottomCenter" RelativeTo="Element">
        <asp:UpdatePanel ID="Updatepanel1" runat="server" UpdateMode="Conditional">

    protected void Button1_Click(object sender, EventArgs e)
        Updatepanel1.ContentTemplateContainer.Controls.Add(new LiteralControl(DateTime.Now.ToString()));

    Of course, if the content of the tooltip is static, you would not need an update panel and programmatic content creation, you can put it between the opening and closing tag of the tooltip.

    Also, the UpdatePanel is needed if you use AJAX for the button click.

    I hope this helps you choose the best path moving forward.


    Marin Bratanov

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Back to Top