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

Show a tooltip to use it like a messagebox

3 Answers 90 Views
ToolTip
This is a migrated thread and some comments may be shown as answers.
Johan
Top achievements
Rank 1
Johan asked on 06 Jun 2012, 07:29 PM
I want to  show a radTooltip from codebehind and use it as a type of msgbox. I want to give the user 'on the fly' database information from serverside, so I need to be able to build the radtooltip content codebehind aswell. Do you have any VB.net example and javascript to accomplish this ?  

I have access to the client user screen pixel where the user clicked. ( I do not want to use a targetcontrolID, tis is goolemap in a <div>) 

How can I call radtooltip to apear clientside on a given x,y pixel on client screen ?

'################################################################################################
This is how I show a radcontextmenu from codebehind/.showat x,y , Does radtooltip have a similar property ? please advise !!!
   ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "RCM", "function pageLoad(){$find('RCM').showAt(" & txtlath.Value & "," & txtlngh.Value & ");}", True)
'################################################################################################

  

  

3 Answers, 1 is accepted

Sort by
0
Kevin
Top achievements
Rank 2
answered on 08 Jun 2012, 12:37 PM
Hello Johan,

I believe you could achieve a somewhat similar functionality if you set the TargetControl to the google map div, but set the RelativeTo property to the browser window with the Position property set to TopLeft. Then in your server-side javascript call, you could use the set_offsetX and set_offsetY methods on the RadToolTip to the x and y coordinates on the screen.

I hope that helps.
0
Johan
Top achievements
Rank 1
answered on 08 Jun 2012, 04:10 PM
Hi Kevin , it works :-) except for the issue of changing x,y position 

ASPX.
 <!-- Test with radtooltip on a mapm, we load the data from a webservice -->
   <telerik:RadToolTipManager ID="RadToolTipManager1" runat="server" Animation="Slide"
        RelativeTo="BrowserWindow" ShowCallout="True" VisibleOnPageLoad="False"
        ShowEvent="FromCode" Position="Topleft" Width="220px" Height="260px" AutoCloseDelay="2000" ManualClose="True" ManualCloseButtonText="Stäng"  AnimationDuration="200">
    <WebServiceSettings Method="GetMailMessagesCount" Path="x_service.asmx" />
         <TargetControls>
            <telerik:ToolTipTargetControl TargetControlID="DIVMAP" Value="1" />
        </TargetControls>
    </telerik:RadToolTipManager>
    
    <script type="text/javascript">
        function xtrakktooltipcodebehind() {
           // alert("Tooltip exekverat från codebehind");
            var tooltip = $find("RadToolTipManager1").get_tooltips()[0];
             tooltip.show();
           
         }
                        
    </script>


VB

Tried this, it' shows the Tooltip but not at the right place X,Y

 Dim tooltipManager As RadToolTipManager = DirectCast((Me.Page.FindControl("RadToolTipManager1")), RadToolTipManager)

To be able to set parameters  would be the best approach if I can get to work !
The changes I do from serverside is not updated on the clientside. !

      tooltipManager.Title = "XTRAKK TOOLTIP DEMO"
      tooltipManager.OffsetX = Session("screenXpx")
      tooltipManager.OffsetY = Session("screenYpx")
      tooltipManager.Width = 300
      tooltipManager.Height = 300
      'tooltipManager.Show()


      ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "xtrakktooltipcodebehind", "xtrakktooltipcodebehind();", True)

and tried this too

' ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "AJAX" & Guid.NewGuid.ToString, "document.getElementById('RadToolTip1').OffsetY='" & Session("screenYpx") & "';", True)
      ' ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "AJAX" & Guid.NewGuid.ToString, "document.getElementById('RadToolTip1').OffsetX='" & Session("screenXpx") & "';", True)
     
And this to 

    ' ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "AJAX" & Guid.NewGuid.ToString, "document.getElementById('RadToolTipManager1').OffsetX='" & Session("screenXpx") & "';", True)
    




0
rdmptn
Top achievements
Rank 1
answered on 08 Jun 2012, 04:39 PM
When working with ScriptControls you need to use $find() to get ar eference to them so that you can use their client-side API, not getElementById.

When using AJAX you need to include the control whose properties you change in the response (usually an UpdatePanel with UpdateMode=Conditional is enough when you call its server Update() method when you need to update the control).

 What I can also suggest is the RadNotification's Server-side Show(newText) method which you can see in this online demo. The RadNotification's client-side API exposes the moveTo() method that can be useful. Note that it has to be shown first (isVisible()).
Tags
ToolTip
Asked by
Johan
Top achievements
Rank 1
Answers by
Kevin
Top achievements
Rank 2
Johan
Top achievements
Rank 1
rdmptn
Top achievements
Rank 1
Share this question
or