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

Show tooltip from Code.

2 Answers 261 Views
ToolTip
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 13 Nov 2014, 08:46 AM
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" >
 <TargetControls>
      <telerik:ToolTipTargetControl TargetControlID=
"LabelStatus" Value="LabelStatus" />
 </TargetControls>
</telerik:RadToolTipManager>

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.
Michael

2 Answers, 1 is accepted

Sort by
0
Michael
Top achievements
Rank 1
answered on 14 Nov 2014, 07:57 AM
i figured it out.

RadToolTip / Manager.Show();

0
Accepted
Marin Bratanov
Telerik team
answered on 14 Nov 2014, 11:56 AM

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: http://demos.telerik.com/aspnet-ajax/tooltip/examples/radtooltipmanagerclientapi/defaultcs.aspx. You can also register the function call from the code-behind, should you need to: http://www.telerik.com/help/aspnet-ajax/window-troubleshooting-javascript-from-server-side.html.

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">
        <ContentTemplate>
        </ContentTemplate>
    </asp:UpdatePanel>
</telerik:RadToolTip>

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

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.

Regards,

Marin Bratanov
Telerik
 

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.

 
Tags
ToolTip
Asked by
Michael
Top achievements
Rank 1
Answers by
Michael
Top achievements
Rank 1
Marin Bratanov
Telerik team
Share this question
or