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

RADToolTip not working..

2 Answers 389 Views
ToolTip
This is a migrated thread and some comments may be shown as answers.
EH Ravidranath
Top achievements
Rank 1
EH Ravidranath asked on 04 Jul 2007, 12:01 PM
HI,
 I am following LoadonDemand example given in Online demo for RADToolTip. but am facing same problem. when the page loads for first time Tooltip is working smoothley but when the page postback happens am not able to get tooltip.

I am using latest hot fix for this RADControl. i.e 6/26/2007 release.

Here am sending sample code, please have a look on this sample.
This is my Default.aspx page


<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

<title>Untitled Page</title>

<link rel="stylesheet" href="Skins/CustomSkin/ToolTip.CustomSkin.css" type="text/css" />

</head>

<body>

<form id="form1" runat="server">

<div>

<br />

<br />

<br />

<br />

<radG:RadGrid ID="RGSample" AllowPaging="true" PageSize="15" EnableAJAX="false" AutoGenerateColumns="false"

runat="server" Height="50%" DataSourceID="AccessDataSource1" OnItemDataBound="RGSample_ItemDataBound"

Skin="Grey" SkinsPath="RadControls/Grid/Skins" CssClass="RadGrid" CellPadding="2"

CellSpacing="2" OnDataBinding="RGSample_DataBinding" OnSortCommand="RGSample_SortCommand" OnDataBound="RGSample_DataBound1" >

<PagerStyle Mode="NumericPages" />

<MasterTableView AllowCustomPaging="False" AllowPaging="True" AllowSorting="True"

GridLines="both" HorizontalAlign="NotSet" PageSize="10" CellPadding="2" CellSpacing="2"

Width="100%" BorderColor="black">

<Columns>

<radG:GridHyperLinkColumn DataTextField="CustomerID" HeaderText="CustomerID" SortExpression="CustomerID"

UniqueName="CustomerID">

</radG:GridHyperLinkColumn>

<radG:GridTemplateColumn HeaderText="ContactName" SortExpression="ContactName" UniqueName="ContactName">

<ItemTemplate>

<asp:Label ID="lblContactName" runat="server" Text='<%#Eval("ContactName") %>'></asp:Label>

</ItemTemplate>

</radG:GridTemplateColumn>

<radG:GridBoundColumn DataField="CompanyName" HeaderText="CompanyName" SortExpression="CompanyName"

UniqueName="CompanyName">

</radG:GridBoundColumn>

<radG:GridTemplateColumn UniqueName="Click">

<ItemTemplate>

<asp:ImageButton ID="imgBtn" runat="server" ImageUrl="~/24find.gif" CommandName="Find" />

</ItemTemplate>

</radG:GridTemplateColumn>

</Columns>

</MasterTableView>

<ClientSettings>

<Scrolling AllowScroll="true" SaveScrollPosition="true" UseStaticHeaders="true" />

</ClientSettings>

</radG:RadGrid>

<asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/Nwind.mdb"

SelectCommand="SELECT top 10 [CustomerID], [CompanyName], [ContactName] FROM [Customers]">

</asp:AccessDataSource>

</div>

<asp:ScriptManager ID="ScriptManager1" runat="server">

</asp:ScriptManager>

<telerik:RadToolTipManager ID="RTMCustomer" runat="server" RelativeTo="Mouse" Position="MiddleRight"

BorderStyle="None" Width="250px" Height="300px" Animation="None" Sticky="true"

ManualClose="true" Skin="CustomSkin" EnableEmbeddedSkins="false" OnAjaxUpdate="RTMCustomer_OnAjaxUpdate"

ShowCallout="true" EnableViewState="false">

</telerik:RadToolTipManager>

</form>

</body>

</html>



Here is my .CS file



using System;

using System.Data;

using System.Configuration;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

using System.Collections.Generic;

public partial class _Default : System.Web.UI.Page

{

protected Dictionary<string, string> controlcollection = new Dictionary<string, string>();

protected void Page_Load(object sender, EventArgs e)

{

}

protected void RGSample_ItemDataBound(object sender, Telerik.WebControls.GridItemEventArgs e)

{

if (e.Item.ItemType == Telerik.WebControls.GridItemType.Item || e.Item.ItemType == Telerik.WebControls.GridItemType.AlternatingItem)

{

System.Web.UI.WebControls.Label lblContactName = (System.Web.UI.WebControls.Label)e.Item.FindControl("lblContactName");

if (lblContactName != null)

{

DataRowView currentRow = (DataRowView)e.Item.DataItem;

if (!controlcollection.ContainsKey(lblContactName.ClientID))

controlcollection.Add(lblContactName.ClientID, currentRow.Row["CustomerID"].ToString());

}

//if (!Page.IsPostBack)

//{

// lblContactName.ID = currentRow.Row["CustomerID"].ToString();

//}

if (this.RTMCustomer != null)

this.RTMCustomer.TargetControls.Add(lblContactName.ClientID, true);

}

}

protected void RTMCustomer_OnAjaxUpdate(object sender, Telerik.Web.UI.ToolTipUpdateEventArgs e)

{

Dictionary<string, string> controls = (Dictionary <string, string>)Session["controlcollection"];

int index = e.TargetControlID.LastIndexOf("_");

//string elementID = e.TargetControlID.Substring(index + 1);

string elementID = controls[e.TargetControlID];

this.UpdateToolTip(elementID, e.UpdatePanel);

}

private void UpdateToolTip(string elementID, UpdatePanel panel)

{

try

{

Control ctrlPopup = Page.LoadControl("Popup.ascx");

panel.ContentTemplateContainer.Controls.Add(ctrlPopup);

PopUp popUp = (PopUp)ctrlPopup;

popUp.CustomerID = elementID;

}

catch (Exception)

{

}

}

protected void RGSample_DataBinding(object sender, EventArgs e)

{

RTMCustomer.TargetControls.Clear();

}

protected void RGSample_SortCommand(object source, Telerik.WebControls.GridSortCommandEventArgs e)

{

RTMCustomer.TargetControls.Clear();

}

protected void RGSample_DataBound1(object sender, EventArgs e)

{

Session.Add("controlcollection", controlcollection);

}

}


Looking forward for your support

Thanks
PRASANNA

2 Answers, 1 is accepted

Sort by
0
Tervel
Telerik team
answered on 05 Jul 2007, 04:27 PM
Hello PRASANNA,

We transfered your forum post into a support thread, as we are sending you an attached project.
We were not able to reproduce the problem using your code - in our case all worked fine (see attached project).

If you are still having the problem, please provide us with a complete runnable project that demonstrates the problem, as well as some more details on what action you take and what the result is.


Best wishes,
Tervel
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
EH Ravidranath
Top achievements
Rank 1
answered on 06 Jul 2007, 07:23 AM
Hi Support Team,

Thank you for your reply. we got that problem working. Here is the working code with modified changes.

"The problem was, after page postback...... TargetControl list use to lose all the control set added to it. so i added it again in OnAjaxUpdate Method.Now its working fine even after page postback "

Take a look at the code.....as well as User control that we used.

Default.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<%@ Register TagPrefix="radG" Namespace="Telerik.WebControls" Assembly="RadGrid.Net2" %>

<%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"

Namespace="System.Web.UI" TagPrefix="asp" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

<%@ Register Src="Popup.ascx" TagName="Popup" 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 runat="server">

<title>Untitled Page</title>

<link rel="stylesheet" href="Skins/CustomSkin/ToolTip.CustomSkin.css" type="text/css" />

</head>

<body>

<form id="form1" runat="server">

<div>

<br />

<br />

<br />

<br />

<radG:RadGrid ID="RGSample" AllowPaging="true" PageSize="15" EnableAJAX="false" AutoGenerateColumns="false"

runat="server" Height="50%" DataSourceID="AccessDataSource1" OnItemDataBound="RGSample_ItemDataBound"

Skin="Grey" SkinsPath="RadControls/Grid/Skins" CssClass="RadGrid" CellPadding="2"

CellSpacing="2" OnDataBinding="RGSample_DataBinding1" OnSortCommand="RGSample_SortCommand1">

<PagerStyle Mode="NumericPages" />

<MasterTableView AllowCustomPaging="False" AllowPaging="True" AllowSorting="True"

GridLines="both" HorizontalAlign="NotSet" PageSize="10" CellPadding="2" CellSpacing="2"

Width="100%" BorderColor="black">

<Columns>

<radG:GridHyperLinkColumn DataTextField="CustomerID" HeaderText="CustomerID" SortExpression="CustomerID"

UniqueName="CustomerID">

</radG:GridHyperLinkColumn>

<radG:GridTemplateColumn HeaderText="ContactName" SortExpression="ContactName" UniqueName="ContactName">

<ItemTemplate>

<asp:Label ID="lblContactName" runat="server" Text='<%#Eval("ContactName") %>'></asp:Label>

</ItemTemplate>

</radG:GridTemplateColumn>

<radG:GridBoundColumn DataField="CompanyName" HeaderText="CompanyName" SortExpression="CompanyName"

UniqueName="CompanyName">

</radG:GridBoundColumn>

<radG:GridTemplateColumn UniqueName="Click">

<ItemTemplate>

<asp:ImageButton ID="imgBtn" runat="server" ImageUrl="~/24find.gif" CommandName="Find" />

</ItemTemplate>

</radG:GridTemplateColumn>

</Columns>

</MasterTableView>

<ClientSettings>

<Scrolling AllowScroll="true" SaveScrollPosition="true" UseStaticHeaders="true" />

</ClientSettings>

</radG:RadGrid>

<asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/Nwind.mdb"

SelectCommand="SELECT top 10 [CustomerID], [CompanyName], [ContactName] FROM [Customers]">

</asp:AccessDataSource>

</div>

<asp:ScriptManager ID="ScriptManager1" runat="server">

</asp:ScriptManager>

<telerik:RadToolTipManager ID="RTMCustomer" runat="server" RelativeTo="Mouse" Position="MiddleRight"

BorderStyle="None" Width="250px" Height="300px" Animation="None" Sticky="true"

ManualClose="true" Skin="CustomSkin" EnableEmbeddedSkins="false" OnAjaxUpdate="RTMCustomer_OnAjaxUpdate"

ShowCallout="true" EnableViewState="false">

</telerik:RadToolTipManager>

</form>

</body>

</html>

 

Default.aspx.cs

using System;

using System.Data;

using System.Configuration;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

using System.Collections.Generic;

public partial class _Default : System.Web.UI.Page

{

protected Dictionary<string, string> controlcollection = new Dictionary<string, string>();

protected void Page_Load(object sender, EventArgs e)

{

}

protected void RGSample_ItemDataBound(object sender, Telerik.WebControls.GridItemEventArgs e)

{

if (e.Item.ItemType == Telerik.WebControls.GridItemType.Item || e.Item.ItemType == Telerik.WebControls.GridItemType.AlternatingItem)

{

System.Web.UI.WebControls.Label lblContactName = (System.Web.UI.WebControls.Label)e.Item.FindControl("lblContactName");

if (lblContactName != null)

{

DataRowView currentRow = (DataRowView)e.Item.DataItem;

if (!controlcollection.ContainsKey(lblContactName.ClientID))

controlcollection.Add(lblContactName.ClientID, currentRow.Row["CustomerID"].ToString());

}

Session.Add("controlcollection", controlcollection);

this.RTMCustomer.TargetControls.Add(lblContactName.ClientID, true);

}

}

protected void RTMCustomer_OnAjaxUpdate(object sender, Telerik.Web.UI.ToolTipUpdateEventArgs e)

{

if (Session["controlcollection"] != null)

{

Dictionary<string, string> controls = (Dictionary<string, string>)Session["controlcollection"];

if (this.RTMCustomer.TargetControls.Count == 0)

{

foreach (string str in controls.Keys)

{

this.RTMCustomer.TargetControls.Add(str, true);

}

}

int index = e.TargetControlID.LastIndexOf("_");

string elementID = controls[e.TargetControlID];

this.UpdateToolTip(elementID, e.UpdatePanel);

}

}

private void UpdateToolTip(string elementID, UpdatePanel panel)

{

try

 

{

Control ctrlPopup = Page.LoadControl("Popup.ascx");

panel.ContentTemplateContainer.Controls.Add(ctrlPopup);

PopUp popUp = (PopUp)ctrlPopup;

popUp.CustomerID = elementID;

}

catch (Exception)

{

}

}

protected void RGSample_DataBinding1(object sender, EventArgs e)

{

//RTMCustomer.TargetControls.Clear();

 

}

protected void RGSample_SortCommand1(object source, Telerik.WebControls.GridSortCommandEventArgs e)

{

//RTMCustomer.TargetControls.Clear();

 

}

}

PopUp.ascx

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="PopUp.ascx.cs" Inherits="PopUp" EnableViewState="false" %>

 

<div>

 

Customer ID: <asp:Label ID="lblCustomerID" runat="server"></asp:Label>

 

<asp:GridView ID="grdOrders" runat="server" AutoGenerateColumns="true" AlternatingRowStyle-CssClass="oddRow"

 

HeaderStyle-CssClass="headRow" FooterStyle-CssClass="bubbleContent" BorderColor="black"

 

Width="100%" EnableViewState="false" >

 

</asp:GridView>

</div>

 

Popup.ascx.cs

using System;

 

using System.Data;

 

using System.Configuration;

 

using System.Collections;

 

using System.Web;

 

using System.Web.Security;

 

using System.Web.UI;

 

using System.Web.UI.WebControls;

 

using System.Web.UI.WebControls.WebParts;

 

using System.Web.UI.HtmlControls;

 

public partial class PopUp : System.Web.UI.UserControl

 

{

private string customerID;

public string CustomerID

{

get

 

{

return customerID;

}

set

 

{

customerID = value;

}

}

protected void Page_Load(object sender, EventArgs e)

{

AccessDataSource dataSource = new AccessDataSource();

dataSource.SelectCommand = "SELECT Top 5 OrderID,OrderDate,ShipAddress,ShipCity FROM Orders WHERE CustomerID=?";

Parameter param = new Parameter("CustomerID",TypeCode.String);

dataSource.SelectParameters.Add(param);

dataSource.SelectParameters["CustomerID"].DefaultValue = this.CustomerID;

dataSource.DataFile = "~/App_Data/Nwind.mdb";

grdOrders.DataSource = dataSource;

//this.AccessDataSource1.SelectParameters["CustomerID"].DefaultValue = this.CustomerID;

 

this.lblCustomerID.Text = this.CustomerID;

this.DataBind();

}

}

Tags
ToolTip
Asked by
EH Ravidranath
Top achievements
Rank 1
Answers by
Tervel
Telerik team
EH Ravidranath
Top achievements
Rank 1
Share this question
or