Two RadTooltipManager on same page

4 posts, 1 answers
  1. jprian
    jprian avatar
    43 posts
    Member since:
    Sep 2006

    Posted 18 Jun 2013 Link to this post

    Hi,

    I've two radtooltipmanager is same page (RadToolTipManager1 and RadToolTipManager2)

    <telerik:RadToolTipManager ID="RadToolTipManager1" runat="server" OnAjaxUpdate="RadToolTipManager1_AjaxUpdate"  RelativeTo="Element" ShowEvent="OnClick" ShowDelay="0" HideEvent="ManualClose" EnableDataCaching="false" EnableViewState="true">
    </telerik:RadToolTipManager>
    <telerik:RadToolTipManager ID="RadToolTipManager2" runat="server" OnAjaxUpdate="RadToolTipManager2_AjaxUpdate" RelativeTo="Element" ShowEvent="OnClick" ShowDelay="0" HideEvent="ManualClose" EnableDataCaching="false" EnableViewState="true">
    </telerik:RadToolTipManager>


    With RadToolTipManager1 I'm loading usercontrol ListaDocumentos.ascx and with RadToolTipManager2 I'm loading usercontrol ListaFichas.ascx.

    Protected Sub RadToolTipManager1_AjaxUpdate(ByVal sender As Object, ByVal args As Telerik.Web.UI.ToolTipUpdateEventArgs)
        Me.UpdateToolTip1(args.Value, args.UpdatePanel)
    End Sub
     
    Protected Sub RadToolTipManager2_AjaxUpdate(ByVal sender As Object, ByVal args As Telerik.Web.UI.ToolTipUpdateEventArgs)
        Me.UpdateToolTip2(args.Value, args.UpdatePanel)
    End Sub
     
    Private Sub UpdateToolTip1(ByVal elementID As String, ByVal panel As UpdatePanel)
        Dim ctrl As UserControl = Me.LoadControl("ListaDocumentos.ascx")
        panel.ContentTemplateContainer.Controls.Add(ctrl)
        Dim detalles As CtrlWeb_ListaDocumentos = DirectCast(ctrl, CtrlWeb_ListaDocumentos)
        detalles.CodigoActivo = ddl_codactivo.SelectedValue
    End Sub
     
    Private Sub UpdateToolTip2(ByVal elementID As String, ByVal panel As UpdatePanel)
        Dim ctrl As UserControl = Me.LoadControl("ListaFichas.ascx")
        panel.ContentTemplateContainer.Controls.Add(ctrl)
        Dim detalles As CtrlWeb_ListaFichas = DirectCast(ctrl, CtrlWeb_ListaFichas)
        detalles.CodigoActivo = ddl_codactivo.SelectedValue
        detalles.FamiliaMorfologica = txt_fmorfologica.Text
    End Sub


    Usercontrols load is correct, each Tooltip shows his associated usercontrol.

    ListaDocumentos.ascx has button. When I click on it RadToolTipManager1_AjaxUpdate is fired an then button click event. 
    ListaFichas.ascx has RadListBox. When I click on it RadToolTipManager2_AjaxUpdate is fired an then SelectedIndexChanged event of radlistbox . 

    It works ok, if I try individually.

    But If I try RadToolTipManager1 first, button_click event is ok, then if I try RadToolTipManager2  after RadToolTipManager1, when I click on radlistbox item, I get RadToolTipManager1_AjaxUpdate event is fired, and then RadToolTipManager2_AjaxUpdate, but not SelectedIndexChanged event, so I must click twice on item to get SelectedIndexChanged event is fired.

    I don't undestand why RadToolTipManager1_AjaxUpdate event is fired when it must be RadToolTipManager2_AjaxUpdate event.



    Please, some help.

    Thanks in advance

  2. Answer
    Ivaylo
    Admin
    Ivaylo avatar
    37 posts

    Posted 21 Jun 2013 Link to this post

    Hello,

    Thank you for your contacting us.

    Regarding your first question, we have created a sample project using the provided code and researched the issue. It seems that the cause for it are the different IDs that the server dynamically assigns to the user controls on each AJAX Request, which causes them to lose their ViewState. We highly recommend explicitly setting those IDs in order to avoid problems such as the one experienced. For this reason, I would suggest the following modification:
    Private Sub UpdateToolTip1(ByVal elementID As String, ByVal panel As UpdatePanel)
        Dim ctrl As UserControl = Me.LoadControl("ListaDocumentos.ascx")
        ctrl.ID = "ListaDocumentosUC"
        panel.ContentTemplateContainer.Controls.Add(ctrl)
        Dim detalles As CtrlWeb_ListaDocumentos = DirectCast(ctrl, CtrlWeb_ListaDocumentos)
        detalles.CodigoActivo = ddl_codactivo.SelectedValue
    End Sub
     
    Private Sub UpdateToolTip2(ByVal elementID As String, ByVal panel As UpdatePanel)
        Dim ctrl As UserControl = Me.LoadControl("ListaFichas.ascx")
        panel.ContentTemplateContainer.Controls.Add(ctrl)
        ctrl.ID = "ListaFichasUC"
        Dim detalles As CtrlWeb_ListaFichas = DirectCast(ctrl, CtrlWeb_ListaFichas)
        detalles.CodigoActivo = ddl_codactivo.SelectedValue
        detalles.FamiliaMorfologica = txt_fmorfologica.Text
    End Sub

    For your convenience, I have attached a sample project based on the provided code, illustrating the described changes.

    As for your second inquiry, regarding the sequence in which AjaxUpdate events are fired, this is the normally expected behavior when working with the Tooltip manager. The intention behind this is to ensure that all user controls in the displayed tooltips are properly loaded since we cannot be sure what has caused the partial postback to the server and that those controls are not already disposed of. Without this safety procedure, the user might be interacting with controls, which are no longer registered on the server, causing undesired behavior.

    I hope that you will find the provided information helpful. Should you have any other questions, feel free to contact us.

    Regards,
    Ivaylo
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. jprian
    jprian avatar
    43 posts
    Member since:
    Sep 2006

    Posted 21 Jun 2013 Link to this post

    Hi Ivaylo, thank you very much.
    It do the trick.
    And thank you for your sample project

    Perfect!!

    Best regards
  5. Joel R
    Joel R avatar
    25 posts
    Member since:
    Nov 2007

    Posted 17 Jan 2014 Link to this post

    this solved my problem... THANKS
Back to Top