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

RadToolTipManager Set Text in Javascript

1 Answer 79 Views
ToolTip
This is a migrated thread and some comments may be shown as answers.
Edward Sudit
Top achievements
Rank 1
Edward Sudit asked on 06 Feb 2014, 04:39 PM
I am currently using the RadToolTipManager successfully to add a usercontrol dynamically, but it loses the "Text" setting after the control is added.  I would like to add the text property back using "OnClientHide" event, but when I add the javascript function and use the set_text method, the page reloads after the text is set.

What is the best way to get this done?  I also tried to set the "OnClientHide" property to a "Protected Sub" on the VB codebehind file, but I get a Javascript error that the method is undefined.  What would be the proper parameters on the codebehind sub that need to be delcared?

Thank you,
Ed Sudit

1 Answer, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 07 Feb 2014, 03:23 PM
Hello Ed,

OnClientHide is a client-side event handler by JavaScript, not by server code.

What I can suggest is using the TItle of the tooltips to display your initial/loading text. Here is a small example:
<div id="target" style="width: 100px; height: 100px; background: yellow;">
    target
</div>
<telerik:RadToolTipManager ID="RadToolTipManager1" runat="server" Title="Please wait..."
                           OnClientBeforeShow="storeOriginalTitle" OnClientHide="resetTitle" OnClientResponseEnd="removeTitle" OnAjaxUpdate="OnAjaxUpdate"
                           Width="200px" Height="120px" RelativeTo="Element" Position="BottomRight">
    <TargetControls>
        <telerik:ToolTipTargetControl IsClientID="true" TargetControlID="target" />
    </TargetControls>
</telerik:RadToolTipManager>
and with the following scripts to handle the title:
function storeOriginalTitle(sender, args) {
    if (!sender.__oldTitle)
        sender.__oldTitle = sender.get_title();
}
function resetTitle(sender, args) {
    if (sender.__oldTitle) {
        sender.set_title(sender.__oldTitle);
    }
}
function removeTitle(sender, args) {
    var activeTooltip = Telerik.Web.UI.RadToolTip.getCurrent();
    if (activeTooltip) {
        activeTooltip.set_title("");
    }
}



Regards,
Marin Bratanov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the UI for ASP.NET AJAX, subscribe to the blog feed now.
Tags
ToolTip
Asked by
Edward Sudit
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Share this question
or