tooltip doubles information from database

3 posts, 1 answers
  1. Kevin
    Kevin avatar
    265 posts
    Member since:
    Jun 2011

    Posted 19 May 2014 Link to this post

    Hi,

    Ok probably doing something wrong but its stumping me.  tyring to get a radtooltipmanager working for instructions for a page.  So if they hover over an image it pops up with the instructions from a database.  The problem is that its is doubling up the information, its like 2 pulls are coming out of the database, so all the text is written and then written agian.

    <div class="cancelpg">
               <h3><asp:Label ID="lblInstruct" runat="server">Hover over this <asp:Image ID="imgHover" runat="server" ImageUrl="~/Images/ViewResources.gif" /> for Instructions</asp:Label>
                   <telerik:RadToolTipManager ID="rttmInstructions" runat="server" Position="Center" Modal="true" ManualClose="true" OnAjaxUpdate="rttmInstructions_AjaxUpdate">
                       <TargetControls>
                           <telerik:ToolTipTargetControl TargetControlID="imgHover" />
                       </TargetControls>
                   </telerik:RadToolTipManager>
               </h3>
           </div>
     
     
    Protected Sub rttmInstructions_AjaxUpdate(sender As Object, e As Telerik.Web.UI.ToolTipUpdateEventArgs) Handles rttmInstructions.AjaxUpdate
           Dim lblInsideToolTip As New Label()
           sql = "Select strMessage from iMAC_Message"
     
           myDataTable = New DataTable
           myDataTable = getReader(sql)
     
           If myDataTable.Rows.Count > 0 Then
               lblInsideToolTip.Text = myDataTable.Rows(0)(0)
           End If
     
           e.UpdatePanel.ContentTemplateContainer.Controls.Add(lblInsideToolTip)
       End Sub
  2. Answer
    Marin Bratanov
    Admin
    Marin Bratanov avatar
    3598 posts

    Posted 20 May 2014 Link to this post

    Hello Kevin,

    VB pages automatically connect event handlers through the Handles clause in the code-behind. Since the control markup has the event handler declared as well, it is simply added and called twice. You can easily confirm this by adding a breakpoint in the server code.

    The same will happen with any server control, for example:

    <asp:Button ID="Button1" Text="test" OnClick="Button1_Click" runat="server" />
    Protected Sub Button1_Click(sender As Object, e As System.EventArgs) Handles Button1.Click
        Response.Write("I was called at: " + Now.Ticks.ToString() + "<br />")
    End Sub

    What you need to do to avoid this is to remove one of the declarations - either from the markup, or the Handles clause. Here is an example from the markup:

    <telerik:RadToolTipManager ID="rttmInstructions" runat="server" Position="Center"
                               Modal="true" HideEvent="ManualClose">
        <TargetControls>
            <telerik:ToolTipTargetControl TargetControlID="imgHover" />
        </TargetControls>
    </telerik:RadToolTipManager>
    on a side note - the correct way to use the manual close button is through the HideEvent property.

    Regards,

    Marin Bratanov
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Kevin
    Kevin avatar
    265 posts
    Member since:
    Jun 2011

    Posted 20 May 2014 in reply to Marin Bratanov Link to this post

    ok i see the problem, thanks for the help.
Back to Top