ToolTip for all controls like DropDownList, ListBox, TextBox, etc....
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;
public class ToolTipHelper
{
public static void BindTooltip(System.Web.UI.Page p)
{
if (p == null p.Form == null)
return;
BindTooltip(p.Form.Controls);
}
public static void BindTooltip(ControlCollection cc)
{
try
{
if (cc == null)
return;
for (int i = 0; i < cc.Count; i++)
{
try
{
Control c = cc[i];
if (c.HasControls())
{
BindTooltip(c.Controls);
}
else
{
if (c.GetType().IsSubclassOf(typeof(ListControl)))
{
ListControl lc = (ListControl)c;
BindTooltip(lc);
}
}
}
catch
{
}
}
}
catch (Exception ex)
{
}
}
public static void BindTooltip(ListControl lc)
{
for (int i = 0; i < lc.Items.Count; i++)
{
lc.Items[i].Attributes.Add("title", lc.Items[i].Text);
}
}
}
Call as
ToolTipHelper.BindTooltip(ControlID);
No comments:
Post a Comment