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

RadTooltipManager OnAjaxUpdate called multiple times on Firefox

3 Answers 120 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Raghav
Top achievements
Rank 1
Raghav asked on 21 Sep 2011, 10:59 AM
Hi,

I am using telerik dll version 2010.2.929.35.
I have a grid in a page and i am showing tooltip on click of each cell, using "radTooltipManager". The contents of the tooltip are dynamic.
The function OnAjaxUpdate is called multiple times in firefox.
In the previous version of the dll, this was working fine. Please help...

Thanks...

Below is the code.

Master page

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="atk" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<head id="Head1" runat="server">
    <title></title>
    <asp:ContentPlaceHolder ID="head" runat="server">
    </asp:ContentPlaceHolder>
</head>
<body>
    <form id="form1" runat="server">
    <atk:ToolkitScriptManager ID="ScriptManager1" EnablePageMethods="true" EnableScriptLocalization="true"
        runat="server" AsyncPostBackTimeout="36000">
    </atk:ToolkitScriptManager>
    <div>
        <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
        </asp:ContentPlaceHolder>
    </div>
    </form>
</body>
</html>

Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="TooltipwithRadgrid.aspx.cs"
    MasterPageFile="~/MasterPage.Master" Inherits="TooltipwithRadgrid" %>
 
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="atk" %>
<asp:Content ID="Content1" ContentPlaceHolderID="Head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:UpdatePanel ID="ss" runat="server" UpdateMode="Conditional">
        <ContentTemplate>
            <telerik:RadToolTipManager runat="server" Width="200px" Height="100px" ContentScrolling="Auto"
                ID="RadToolTipManager1" AutoCloseDelay="90000000" RelativeTo="Element" Animation="Fade"
                HideEvent="LeaveTargetAndToolTip" ManualClose="false" Skin="Default" OnAjaxUpdate="OnAjaxUpdate"
                ShowEvent="OnClick" RenderInPageRoot="true" AnimationDuration="100">
            </telerik:RadToolTipManager>
            <asp:Panel ID="pnlData" runat="server">
            </asp:Panel>
        </ContentTemplate>
    </asp:UpdatePanel>
    <asp:Button ID="btn" runat="server" Text="bind grid" />
</asp:Content>

Default.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Telerik.Web.UI;
using System.Web.UI.HtmlControls;
 
 
 
public class DynamicTemplateRadGridHandler : ITemplate
{
 
    GridItemType itemtype;
 
    Telerik.Web.UI.RadToolTipManager radToolTipManager;
    string columnName;
 
    /// <summary>
    /// Constructor for dynamic template
    /// </summary>
    /// <param name="item_type">Itemtype(Header/Dataitem)</param>
    /// <param name="dataload_Name">name of the dataload</param>
    public DynamicTemplateRadGridHandler(GridItemType item_type, string column_Name, Telerik.Web.UI.RadToolTipManager radToolTip_Manager)
    {
        columnName = column_Name;
        itemtype = item_type;
        radToolTipManager = radToolTip_Manager;
    }
 
    #region ITemplate Members
 
    /// <summary>
    /// creates templates for header and items
    /// </summary>
    /// <param name="container"></param>
    public void InstantiateIn(Control Container)
    {
        switch (itemtype)
        {
            case GridItemType.Header:
                Literal header_ltrl = new Literal();
                header_ltrl.Text = "<b>" + columnName + "</b>";
                Container.Controls.Add(header_ltrl);
                break;
            case GridItemType.Item:
            case GridItemType.AlternatingItem:
                LinkButton field_lbl = new LinkButton();
                field_lbl.ID = columnName;
                field_lbl.Text = String.Empty;
                field_lbl.DataBinding += new EventHandler(OnDataBinding);
                Container.Controls.Add(field_lbl);
                break;
 
 
        }
    }
 
    #endregion
 
    /// <summary>
    /// used to bind data to dynamic templates created by using InstantiateIn
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    void dataTable_DataBinding(object sender, EventArgs e)
    {
        object bound_value_obj = null;
        Control ctrl = (Control)sender;
        GridDataItem data_item_container = (GridDataItem)ctrl.NamingContainer;
        bound_value_obj = DataBinder.GetPropertyValue(data_item_container.DataItem, columnName);
        LinkButton lnk = (LinkButton)sender;
        lnk.Text = bound_value_obj.ToString();
        radToolTipManager.TargetControls.Add(lnk.ClientID, "Tool tip Data", true);
 
    }
 
    private void OnDataBinding(object sender, EventArgs e)
    {
        object bound_value_obj = null;
        Control ctrl = (Control)sender;
        GridDataItem data_item_container = (GridDataItem)ctrl.NamingContainer;
        bound_value_obj = DataBinder.GetPropertyValue(data_item_container.DataItem, columnName);
        LinkButton lnk = (LinkButton)sender;
        lnk.Text = bound_value_obj.ToString();
        radToolTipManager.TargetControls.Add(lnk.ClientID, "Tool tip Data", true);
 
    }
 
 
}
 
public partial class TooltipwithRadgrid : System.Web.UI.Page
{
    public RadGrid grdHierarchy = null;
    protected void Page_Load(object sender, EventArgs e)
    {
 
        btn.Click += new EventHandler(btn_Click);
    }
 
    protected void btn_Click(object sender, EventArgs e)
    {
        creatGrid();
    }
    protected void Page_Init(object sender, EventArgs e)
    {
        pnlData.Controls.Clear();
        grdHierarchy = null;
 
    }
 
    protected void rad_OnItemDataBound(object sender, GridItemEventArgs e)
    {
        if (e.Item.ItemType == GridItemType.Item || e.Item.ItemType == GridItemType.AlternatingItem)
        {
            LinkButton lnk = e.Item.FindControl("lnk4") as LinkButton;
            RadToolTipManager1.TargetControls.Add(lnk.ClientID, "fffff123", true);
        }
    }
    protected void OnAjaxUpdate(object sender, ToolTipUpdateEventArgs args)
    {
        //this.UpdateToolTip(args.Value, args.UpdatePanel);
        Label ctrl = new Label();
        ctrl.Text = args.Value + "  test data.";
        args.UpdatePanel.ContentTemplateContainer.Controls.Add(ctrl);
        RadToolTipManager1.UpdatePanel.Update();
 
    }
    private void UpdateToolTip(string elementID, UpdatePanel panel)
    {
        Label ctrl = new Label();
        ctrl.Text = elementID + "  test data.";
        panel.ContentTemplateContainer.Controls.Add(ctrl);
        RadToolTipManager1.UpdatePanel.Update();
 
    }
    private void creatGrid()
    {
        DataTable dt = new DataTable();
        for (int i = 0; i < 10; i++)
        {
            dt.Columns.Add("Column"+i);
        }
         
        for (int i = 0; i < 10; i++)
        {
            DataRow dr = dt.NewRow();
            foreach (DataColumn clm in dt.Columns)
            {
                dr[clm] = "Value" + i;
            }
            
             
            dt.Rows.Add(dr);
        }
 
 
        grdHierarchy = new RadGrid();
        grdHierarchy.ID = "grdHierarchy";
         
        grdHierarchy.ID = "grdHierarchy";
        grdHierarchy.EnableTheming = true;
        grdHierarchy.Width = Unit.Pixel(200);
        grdHierarchy.AutoGenerateColumns = false;
        grdHierarchy.EnableLinqExpressions = false;
        grdHierarchy.MasterTableView.Columns.Clear();
        grdHierarchy.AllowPaging = false;
        grdHierarchy.AllowSorting = false;
        grdHierarchy.EnableViewState = true;
        grdHierarchy.MasterTableView.EnableViewState = true;
        grdHierarchy.ClientSettings.EnableRowHoverStyle = true;
        grdHierarchy.ClientSettings.EnableAlternatingItems = true;
        grdHierarchy.ClientSettings.Scrolling.AllowScroll = true;
        grdHierarchy.ClientSettings.Scrolling.FrozenColumnsCount = 1;
        grdHierarchy.ClientSettings.Scrolling.SaveScrollPosition = true;
        grdHierarchy.ClientSettings.Scrolling.ScrollHeight = Unit.Pixel(100);
        grdHierarchy.ClientSettings.Scrolling.UseStaticHeaders = true;
        foreach (DataColumn clm in dt.Columns)
        {
            GridTemplateColumn ItemTmpField = new GridTemplateColumn();
 
            ItemTmpField.HeaderTemplate = new DynamicTemplateRadGridHandler(GridItemType.Header, clm.ColumnName, RadToolTipManager1);
            ItemTmpField.ItemTemplate = new DynamicTemplateRadGridHandler(GridItemType.Item, clm.ColumnName, RadToolTipManager1);
 
            grdHierarchy.MasterTableView.Columns.Add(ItemTmpField);
        }
        grdHierarchy.DataSource = dt;
        grdHierarchy.DataBind();
        pnlData.Controls.Clear();
        pnlData.Controls.Add(grdHierarchy);
 
 
    }
}



3 Answers, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 22 Sep 2011, 01:17 PM
Hi Raghav,

I tested your code with the RadControls version in question. What I have concluded is that this issue stems from the AjaxControlToolKit assembly. Its mere presence in the Bin folder of the project causes some of the MS AJAX scripts to get reference from the ACT assembly, but these versions are somehow modified and do not work properly, especially with regard to attaching/detaching client handlers. In this case it seems that the client handler the RadToolTIpManager needs to attach only once gets attached numerous times due to the wrong scripts from the ACT assembly, which results in the multiple AJAX requests. Once I removed it (excluded is also enough) things seem to be working as expected: http://screencast.com/t/mdN5qtMMu. On a side note - you do not need to manually call the update() method of the tooltip manager's update panel in the OnAjaxUpdate method. I would also recommend that you upgrade to the latest version of the RadControls, as there are many fixes and features added since Q2 2010, the one closest related to this case is a fix with the HideEvent="LeaveTargetAndToolTip".


Regards,
Marin
the Telerik team
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 their blog feed now
0
Raghav
Top achievements
Rank 1
answered on 23 Sep 2011, 08:47 PM
Hi Marin,

Thanks for your research on this issue. However, we cannot do away with the ACT assembly, I tried reproducing the same issue with the earlier DLL (versioned: 2010.1.415.35). The implementation we have works perfectly fine, even in the presence of ACT DLL. We cannot upgrade immediately to the new version at this moment as we have a planned release very shortly and need a resolution to this issue. Any help in this respect would be highly appreciated.

Thanks!
0
Marin Bratanov
Telerik team
answered on 26 Sep 2011, 02:40 PM
Hello Raghav,

I am sorry to say that there isn't a simple workaround available for this. What I can advise is that you use a version that does not display this behavior and upgrade when possible. The story of this issue is a little more complicated than it seems at first glance. For the Q2 2010 release there has been a fix in our code so that some scenarios are handled properly. Around this time the new version of the ACT introduced another change which results in the same behavior, but for different reasons. This has also been taken care of in our code, but for the Q1 2011 release.

This means that you should either stick with the Q1 2010 version, or upgrade at least to the Q1 2011 (I strongly advise that you upgrade to the latest available when you do so).

Greetings,
Marin
the Telerik team
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 their blog feed now
Tags
General Discussions
Asked by
Raghav
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Raghav
Top achievements
Rank 1
Share this question
or