Tooltipified RadGrid - tool tip isn't populating

2 posts, 0 answers
  1. Gulfam
    Gulfam avatar
    2 posts
    Member since:
    Jan 2011

    Posted 01 Feb 2011 Link to this post

    Hello,

    I'm trying to implement the Tooltipified RadGrid in my web user control.  I've followed all the instructions  according to your attached file telerikradtooltipsample.zip. I'm also using this example: http://demos.telerik.com/aspnet-ajax/tooltip/examples/targetcontrolsandajax/defaultcs.aspx
    I'm working on DotNetNuke and the following exception appears.
    Error: TestToolTip is currently unavailable.
    DotNetNuke.Services.Exceptions.ModuleLoadException: Object reference not set to an instance of an object. ---> System.NullReferenceException: Object reference not set to an instance of an object. at DotNetNuke.UI.Modules.ModuleHost.LoadModuleControl() --- End of inner exception stack trace ---
    My code snippets:

    TestToolTip.ascx
    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="TestToolTip.ascx.cs" Inherits="SU_SaleStatisticImport.TestToolTip" %>
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="Telerik" %>
    <%@ Register Src="ActivityDetails.ascx" TagName="ActivityDetails" TagPrefix="uc1" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <head id="Head1" runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <asp:ScriptManager runat="server">
        </asp:ScriptManager>
        <Telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
        </Telerik:RadAjaxLoadingPanel>
        <Telerik:RadToolTipManager ID="RadToolTipManager1" OffsetY="-1" HideEvent="ManualClose"
            Width="250" Height="350" runat="server" EnableShadow="true" OnAjaxUpdate="OnAjaxUpdate"
            RelativeTo="Element" Position="MiddleRight">
        </Telerik:RadToolTipManager>
        <Telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <Telerik:AjaxSetting AjaxControlID="rgCampaigns">
                    <UpdatedControls>
                        <Telerik:AjaxUpdatedControl ControlID="rgCampaigns" LoadingPanelID="RadAjaxLoadingPanel1" />
                        <Telerik:AjaxUpdatedControl ControlID="RadToolTipManager1" />
                    </UpdatedControls>
                </Telerik:AjaxSetting>
            </AjaxSettings>
        </Telerik:RadAjaxManager>
        <Telerik:RadGrid ID="rgCampaigns" runat="server" OnItemDataBound="rgCampaigns_ItemDataBound"
            AutoGenerateColumns="false">
            <MasterTableView runat="server" DataKeyNames="GlobalCode">
                <Columns>
                    <Telerik:GridTemplateColumn HeaderText="First">
                        <ItemTemplate>
                            <asp:Label ID="lblTitle" runat="server" Text="Show ToolTip"></asp:Label>
                        </ItemTemplate>
                    </Telerik:GridTemplateColumn>
                    <Telerik:GridBoundColumn DataField="SecondColumn" HeaderText="Second">
                    </Telerik:GridBoundColumn>
                </Columns>
            </MasterTableView>
        </Telerik:RadGrid>
        </form>
    </body>
    </html>

    TestToolTip.ascx.cs
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using Telerik.Web.UI;
     
    namespace SU_SaleStatisticImport
    {
        public partial class TestToolTip : System.Web.UI.UserControl
        {
            protected System.Data.DataTable GetData()
            {
                System.Data.DataTable tbl = new System.Data.DataTable();
                tbl.Columns.Add(new System.Data.DataColumn("GlobalCode"));
                tbl.Columns.Add(new System.Data.DataColumn("SecondColumn"));
                tbl.Columns.Add(new System.Data.DataColumn("ThirdColumn"));
                tbl.Columns.Add(new System.Data.DataColumn("FourthColumn"));
                tbl.Rows.Add(new object[] { "firstRecord1", "firstRecord2", "firstRecord3", "firstRecord4" });
                tbl.Rows.Add(new object[] { "secondRecord1", "secondRecord2", "secondRecord3", "secondRecord4" });
                tbl.Rows.Add(new object[] { "thirdRecord1", "thirdRecord2", "thirdRecord3", "thirdRecord4" });
                return tbl;
     
            }
            protected void Page_Load(object sender, EventArgs e)
            {
                if (!IsPostBack)
                {
                    rgCampaigns.DataSource = GetData();
                    rgCampaigns.DataBind();
                }
            }
     
            protected void OnAjaxUpdate(object sender, ToolTipUpdateEventArgs args)
            {
                this.UpdateToolTip(args.Value, args.UpdatePanel);
            }
            private void UpdateToolTip(string ActivityCode, UpdatePanel panel)
            {
                Control ctrl = Page.LoadControl("~/ActivityDetails.ascx");
                panel.ContentTemplateContainer.Controls.Add(ctrl);
     
                ActivityDetails details = (ActivityDetails)ctrl;
                details.ActivityCode = ActivityCode;
     
            }
     
            protected void rgCampaigns_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
            {
     
                if (e.Item.ItemType == GridItemType.Item || e.Item.ItemType == GridItemType.AlternatingItem)
                {
                    Control target = e.Item.FindControl("lblTitle");
                    if (!Object.Equals(target, null))
                    {
                        if (!Object.Equals(this.RadToolTipManager1, null))
                        {
                            //Add the button (target) id to the tooltip manager
                            this.RadToolTipManager1.TargetControls.Add(target.ClientID, (e.Item as GridDataItem).GetDataKeyValue("GlobalCode").ToString(), true);
     
                        }
                    }
                }
     
     
            }
        }
    }

    ActivityDetails.ascx
    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ActivityDetails.ascx.cs" Inherits="SU_SaleStatisticImport.ActivityDetails" %>
    <asp:label id="lbltest" runat="server" text="Label"></asp:label>

    ActivityDetails.ascx.cs
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
     
    namespace SU_SaleStatisticImport
    {
        public partial class ActivityDetails : System.Web.UI.UserControl
        {
            public string ActivityCode
            {
                get
                {
                    if (ViewState["ActivityCode"] == null)
                    {
                        return "";
                    }
                    return (string)ViewState["ActivityCode"];
                }
                set
                {
     
                    ViewState["ActivityCode"] = value;
     
                }
            }
     
            protected void Page_Load(object sender, EventArgs e)
            {
                lbltest.Text += "<br>Activity code: " + ActivityCode;
            }
        }
    }
  2. Svetlina Anati
    Admin
    Svetlina Anati avatar
    2795 posts

    Posted 03 Feb 2011 Link to this post

    Hi Gulfam,

     The error is a general ASP.NET error that shows that some object you have referenced is null and you are trying to set its property or call its method. I can see from your code that this is not the target nor the RadToolTipManager but I cannot tell which is the missing object without debugging a working sample.

    What I can suggest is to carefully debug the server code until you find out which is the missing object - this should be your custom code because the RadToolTipManager itself does not have null references to child controls.

    In case you need further assistance, please prepare a sample, fully runnable reproduction demo with the problem isolated (do not include the Telerik.Web.UI.dll), upload it somewhere on the net and provide a download url along with detailed reproduction steps and we will do our best to help.

    Best wishes,
    Svetlina
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top