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
TestToolTip.ascx.cs
ActivityDetails.ascx
ActivityDetails.ascx.cs
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">
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
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;
}
}
}