Server Side Show

7 posts, 0 answers
  1. CmdJerry
    CmdJerry avatar
    7 posts
    Member since:
    May 2007

    Posted 11 Jan 2008 Link to this post

    I want to be able to show a tooltip from server side postback. I have a javascript function:


    function

    ShowToolTip()

    {

    var tooltip = $find("<%= this.RadToolTip1.ID %>");

    tooltip.show();

    }


    If I call this function from an input button, onclick, the tooltip shows up just fine. If I register the function as a startup script on the server side, the function is called, but the client side tooltip == null. I'm assuming this means that it has not yet been created. I tried calling the function from onload (which occurs after startup script), and it is also null. Is there anyway I can get the desired functionality? Essentially, I'm trying to get the same functionality as RadWindow.VisibleOnPageLoad -- for RadTooltip instead of RadWindow.
  2. Tervel
    Admin
    Tervel avatar
    1337 posts

    Posted 14 Jan 2008 Link to this post

    Hello CmdJerry,

    The correct event to use, which guarantees that MS AJAX controls on the page are created (and the Prometheus controls are built on top of MS AJAX) is the Sys.Application.add_init

    If you examine the generated page source where MS AJAX controls are present in the page bottom you will see that they are created during this event as well - and the event itself is fired after the window.onload event.

    Thus the following code should work:
    Sys.Application.add_init(function() {

    var tooltip = $find("<%= this.RadToolTip1.ID %>");
    tooltip.show();


    });

    Of course, to avoid a javascript error, when showing the tooltip programatically you should set the property RelativeTo = "Element" (which you probably already do).

    On a side note, in the coming Q1 we do plan to extend the tooltip and provide serverside methods such as Show and Hide, similar to the ModalPopupExtender control available in the MS AjaxControlToolkit.


    Kind regards,
    Tervel
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. CmdJerry
    CmdJerry avatar
    7 posts
    Member since:
    May 2007

    Posted 14 Jan 2008 Link to this post

    This almost works. You see, when I put the code you described on server side:

    ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "tooltip", "Sys.Application.add_init(function() {var tooltip=$find(\"" + this.RadToolTip1.ID + "\");tooltip.show();});", true);

    I get the following added to the bottom of my code:

    <script type="text/javascript">
    //<![CDATA[
    Sys.Application.add_init(function() {var tooltip=$find("RadToolTip1");tooltip.show();});
    Sys.Application.initialize();
    Sys.Application.add_init(function() {
        $create(Telerik.Web.UI.RadToolTip, {"animation":0,"clientStateFieldID":"RadToolTip1_ClientState","contentScrolling":0,"formID":"form1","manualClose":true,"position":22,"relativeTo":1,"showEvent":16,"skin":"Default","targetControlID":"form1"}, null, null, $get("RadToolTip1"));
    });
    //]]>
    </script>

    As you can see my code gets added to the queue first. So, tooltip == null again. (Also, in case you were wondering, this needs to work for both an AJAX and normal postback.)
  4. Tervel
    Admin
    Tervel avatar
    1337 posts

    Posted 15 Jan 2008 Link to this post

    Hi CmdJerry,

    Then a small timeout should make things work:

    Sys.Application.add_init(function()
    {
    window.setTimeout(function()

    {
       var tooltip = $find("<%= this.RadToolTip1.ID %>");
       tooltip.show();





    }, 10);

    });



    Sincerely yours,
    Tervel
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  5. CmdJerry
    CmdJerry avatar
    7 posts
    Member since:
    May 2007

    Posted 15 Jan 2008 Link to this post

    It is now works on the first postback, but then throws an error on any subsequent postback. I'm using a custom ascx control to encapsulate my tooltip control. Within the website the control may be used with a normal postback page or an AJAX page. All pages contain a ScriptManager. On a normal postback everything works fine. On an AJAX postback, the second time the tooltip is register, I get a javascript error: "Sys.InvalidOperationException: Two components with the same id 'ct100_pvsSummary_rttSummary' can't be added to the application."

    Also, the setTimeout worked great. I was able to get a similar functionality using Sys.Application.add_load instead of Sys.Application.add_init with the setTimeout. This seemed to take care of the order of operations issue mentioned previously.
  6. Tervel
    Admin
    Tervel avatar
    1337 posts

    Posted 16 Jan 2008 Link to this post

    Hi CmdJerry,

    There was such a problem reported, and we fixed it in the Prometheus Q3 SP1 that was released yesterday, January 15th, 2008.

    Please install the latest Prometheus, and let us know whether the problem persists.

    Sincerely yours,
    Tervel
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  7. CmdJerry
    CmdJerry avatar
    7 posts
    Member since:
    May 2007

    Posted 16 Jan 2008 Link to this post

    That did it. Everything works great now. Thanks for all your help.
Back to Top