Hi
My Rad tool tip is working perfectly fine as long as it is the only radtool tip in that page. If I have more than one radtool tips in a page only one tooltip is working.
My Radtool tip is created programmatically and added to a control and that control is added to the web part's control collection.
So when I have more than one web parts in a page only one web part's rad tool tip works. My code is below. Please tell me what I'm doing wrong here.
In the webpart I have this control called Link Bubble
<Controls:ContentHelp ID="LinkBubble" runat="server" ContentId="viewuploadfile" TargetControlID="WebPartHelpVerb">
</Controls:ContentHelp>
The above control's implementation is below.
using System;
using System.Text;
using System.Web.UI;
using System.Web;
using System.Xml;
using System.Xml.XPath;
using System.Configuration;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;
using Telerik.Web.UI;
using AjaxControlToolkit;
using Cts.Bamboo.UI.Controls;
using Cts.Web.Issuer.Utilities;
namespace Cts.Web.Issuer.UI.Controls
{
/// <summary>
///
/// </summary>
public class ContentHelp : CompositeControl
{
#region MODIFIERS
private RadToolTip _radtooltip;
private Cts.Bamboo.UI.Controls.ContentPanel _content;
private string _controlPositioningStyleId = string.Empty;
internal Parameter countryCode = new Parameter("country-code", TypeCode.String, (string)HttpContext.Current.Profile[ProfileVars.IssuerCountryCode]);
#endregion
/// <summary>
///
/// </summary>
public ContentHelp()
{ }
#region PROPERTIES
/// <summary>
///
/// </summary>
public string ContentId
{
get { base.EnsureChildControls(); return _content.SelectParameters[0].DefaultValue; }
set { base.EnsureChildControls(); _content.SelectParameters[0].DefaultValue = value;}
}
/// <summary>
///
/// </summary>
public string TargetControlID
{
get { base.EnsureChildControls(); return _radtooltip.TargetControlID; }
set { base.EnsureChildControls(); _radtooltip.TargetControlID = value; }
}
/// <summary>
///
/// </summary>
public string ControlPositioningStyleId
{
get { base.EnsureChildControls(); return _controlPositioningStyleId; }
set { base.EnsureChildControls(); _controlPositioningStyleId = value; }
}
/// <summary>
///
/// </summary>
public RadToolTip Extender
{
get { base.EnsureChildControls(); return _radtooltip; }
}
#endregion
#region DESIGNER CREATION
/// <summary>
///
/// </summary>
protected override void CreateChildControls()
{
this.Controls.Clear();
this._content = new Cts.Bamboo.UI.Controls.ContentPanel();
this._content.ItemTemplate = new HelpTemplate(this);
this._content.Source = "webpart-help";
{
QueryStringParameter helpIdparam = new QueryStringParameter("help-id", "help");
this._content.SelectParameters.Add(helpIdparam);
this._content.SelectParameters.Add(countryCode);
}
_radtooltip = new RadToolTip();
_radtooltip.ID = "popup";
_radtooltip.ShowEvent = ToolTipShowEvent.OnClick;
_radtooltip.ShowDelay = 0;
_radtooltip.ManualClose = true;
_radtooltip.Position = ToolTipPosition.MiddleRight;
_radtooltip.RelativeTo = ToolTipRelativeDisplay.Element;
_radtooltip.TargetControlID = this.TargetControlID;
_radtooltip.Controls.Add(this._content);
_radtooltip.Animation = ToolTipAnimation.FlyIn;
this.Controls.Add(this._radtooltip);
this.ChildControlsCreated = true;
}
#endregion
#region PRE-RENDER
/// <summary>
///
/// </summary>
/// <param name="e"></param>
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
if (((HelpTemplate)this._content.ItemTemplate).Nav.ToString() != "")
{
((System.Web.UI.WebControls.WebParts.WebPart)Parent).HelpUrl = ((HelpTemplate)this._content.ItemTemplate).Nav.ToString();
}
}
#endregion
/// <summary>
///
/// </summary>
/// <param name="writer"></param>
protected override void Render(HtmlTextWriter writer)
{
if (string.IsNullOrEmpty(ControlPositioningStyleId))
{
ControlPositioningStyleId = "bubble-wrapper";
}
writer.AddAttribute(HtmlTextWriterAttribute.Class, ControlPositioningStyleId);
writer.RenderBeginTag(HtmlTextWriterTag.Div);
base.RenderChildren(writer);
writer.RenderEndTag();
}
#region INNER CLASS HELP TEMPLATE
private class HelpTemplate : ITemplate
{
#region modifiers and properties
string morehelptext = string.Empty;
string title = string.Empty;
string shortdescription = string.Empty;
string navigationalurl = string.Empty;
string longdescription = string.Empty;
string longdescriptionurl = string.Empty;
string navurl = string.Empty;
private ContentHelp _help;
public HelpTemplate(ContentHelp help)
{
this._help = help;
}
public ContentHelp HelpContent
{
get { return _help; }
set { _help = value; }
}
public string Nav
{
get { return navurl; }
set { navurl = value; }
}
#endregion
void ITemplate.InstantiateIn(Control container)
{
container.DataBinding += delegate
{
//container that holds the text
object dataItem = ((IDataItemContainer)container).DataItem;
#region web content values
//'More Help' text
morehelptext = (string)HttpContext.GetGlobalResourceObject("Issuer/Help", "/Issuer/Help/Url");
XPathNavigator nav = ((IXPathNavigable)dataItem).CreateNavigator();
//title
if (nav.Select("title").Count > 0) //if "title" node exist
{
title = (String)nav.SelectSingleNode("title").ToString();
}
//url
if (nav.Select("url").Count > 0) //if url node exist
{
navigationalurl = nav.SelectSingleNode("url").Value.Trim();
}
//short description
if (nav.Select("short-description").Count > 0) //if "short-description" node exist
{
shortdescription = nav.SelectSingleNode("short-description").Value.Trim();
}
//long description
if (nav.Select("long-description").Count > 0) //if "long-description" node exist
{
longdescription = nav.SelectSingleNode("long-description").Value.Trim();
}
// long dscriontion utl
if (ConfigurationSettings.AppSettings["HelpLongDescURL"] != null)
{
longdescriptionurl = ConfigurationSettings.AppSettings["HelpLongDescURL"].ToString();
}
#endregion
#region Test only
//@@@@@@@@@@@TEST ONLY........................
//longdescription = "";
//shortdescription = "";
//navigationalurl = "http://computershare.com/";
//title = "";
//navigationalurl = "";
//@@@@@@@@@@@TEST ONLY........................
//string val = (string)System.Web.HttpContext.Current.Profile.GetPropertyValue("CountryCode");
#endregion
#region main content
Literal bubbleMainLtrl = new Literal();
bubbleMainLtrl.Text = "<h5>" + this.title + "</h5>" + this.shortdescription;
container.Controls.Add(bubbleMainLtrl);
HtmlGenericControl utltext = new HtmlGenericControl();
LiteralControl urrLtrl = new LiteralControl("</div><div class=\"bubblelink\">");
#endregion
#region logic
//applying the logic
if (navigationalurl != string.Empty) //if there is a url : display url
{
if (this.shortdescription != string.Empty || this.title != string.Empty)
{
Nav = navigationalurl;
urrLtrl.Text = "<a href='" + navigationalurl + "' originalAttribute="href" originalPath="" + navigationalurl + "" originalAttribute="href" originalPath="" + navigationalurl + "" >" + morehelptext + "</a>";
utltext.Controls.Add(urrLtrl);
container.Controls.Add(utltext);
}
else
{
Nav = navigationalurl;
this.HelpContent._radtooltip.Enabled = false;
}
}
else if (longdescription != string.Empty)
{
//short desc
if (this.shortdescription != string.Empty)
{
if (this.HelpContent.ContentId != null)
{
//urrLtrl.Text = "<a href='" + longdescriptionurl + this.HelpContent.ContentId + "' originalAttribute="href" originalPath="" + longdescriptionurl + this.HelpContent.ContentId + "" originalAttribute="href" originalPath="" + longdescriptionurl + this.HelpContent.ContentId + "" originalAttribute="href" originalPath="" + longdescriptionurl + this.HelpContent.ContentId + "" originalAttribute="href" originalPath="" + longdescriptionurl + this.HelpContent.ContentId + "" >" + morehelptext + "</a>";
urrLtrl.Text = "<a href='" + longdescriptionurl + this.HelpContent.ContentId + "' originalAttribute="href" originalPath="" + longdescriptionurl + this.HelpContent.ContentId + "" originalAttribute="href" originalPath="" + longdescriptionurl + this.HelpContent.ContentId + "" target='_blank' >" + morehelptext + "</a>";
utltext.Controls.Add(urrLtrl);
container.Controls.Add(utltext);
Nav = longdescriptionurl + this.HelpContent.ContentId;
}
else
{
//disable the bubble
this.HelpContent._radtooltip.Enabled = false;
}
}
else //no short description only long description
{
if (this.HelpContent.ContentId != null)
{
//System.Web.HttpContext.Current.Response.Redirect(longdescriptionurl + this.HelpContent.ContentId, false);
Nav = longdescriptionurl + this.HelpContent.ContentId;
this.HelpContent._radtooltip.Enabled = false;
}
}
}
else //if no long desc and no url
{
if (shortdescription == string.Empty) //no short desc
{
this.HelpContent._radtooltip.Enabled = false;
}
else
{ /*dislpay the short description only*/ }
}
#endregion
this._help._radtooltip.Title = this.title;
this._help._radtooltip.Text = this.shortdescription + "<br />" + urrLtrl.Text;
};
}
}
#endregion
}
}
<
Controls:ContentHelp ID="LinkBubble1" runat="server" ContentId="viewuploadfile1" TargetControlID="WebPartHelpVerb">
</
Controls:ContentHelp>
<Controls:ContentHelp ID="LinkBubble2" runat="server" ContentId="viewuploadfile2" TargetControlID="WebPartHelpVerb">
</
Controls:ContentHelp>
only one of them is work. Please help
Thanks
Raj