Show a tooltip to use it like a messagebox

4 posts, 0 answers
  1. Johan
    Johan avatar
    6 posts
    Member since:
    May 2012

    Posted 06 Jun 2012 Link to this post

    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)
    '################################################################################################

      

      
  2. Kevin
    Kevin avatar
    360 posts
    Member since:
    Jul 2012

    Posted 08 Jun 2012 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Johan
    Johan avatar
    6 posts
    Member since:
    May 2012

    Posted 08 Jun 2012 Link to this post

    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)
        




  5. rdmptn
    rdmptn avatar
    72 posts
    Member since:
    Aug 2011

    Posted 08 Jun 2012 Link to this post

    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()).
Back to Top