RadToolTipManager Set Text in Javascript

2 posts, 0 answers
  1. Edward Sudit
    Edward Sudit avatar
    29 posts
    Member since:
    Aug 2012

    Posted 06 Feb 2014 Link to this post

    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
  2. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3602 posts

    Posted 07 Feb 2014 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top