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

Server Side Show

6 Answers 189 Views
ToolTip
This is a migrated thread and some comments may be shown as answers.
CmdJerry
Top achievements
Rank 1
CmdJerry asked on 11 Jan 2008, 04:31 PM
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.

6 Answers, 1 is accepted

Sort by
0
Tervel
Telerik team
answered on 14 Jan 2008, 01:44 PM
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
0
CmdJerry
Top achievements
Rank 1
answered on 14 Jan 2008, 10:11 PM
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.)
0
Tervel
Telerik team
answered on 15 Jan 2008, 08:25 AM
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
0
CmdJerry
Top achievements
Rank 1
answered on 15 Jan 2008, 05:06 PM
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.
0
Tervel
Telerik team
answered on 16 Jan 2008, 08:27 AM
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
0
CmdJerry
Top achievements
Rank 1
answered on 16 Jan 2008, 08:57 PM
That did it. Everything works great now. Thanks for all your help.
Tags
ToolTip
Asked by
CmdJerry
Top achievements
Rank 1
Answers by
Tervel
Telerik team
CmdJerry
Top achievements
Rank 1
Share this question
or