Torna al Thread
public class MyLabel : System.Web.UI.WebControls.Label
{
public int MaxTextLength { get; set; }
public override string Text
{
get
{
if (MaxTextLength == 0)
return base.Text;
else
{
if (base.Text.Length > MaxTextLength)
return base.Text.Substring(0, this.MaxTextLength) + "...";
else
return base.Text;
}
}
set
{ base.Text = value; }
}
public string FullText { get { return base.Text; } }
public MyLabel()
{ this.MaxTextLength = 0; }
//come sopra, una possibile variante al tuo bottone: tutto il testo è visibile nel tooltip, passando il mouse sul testo
protected override void OnPreRender(EventArgs e)
{
if (base.Text.Length > MaxTextLength)
{
this.ToolTip = this.FullText;
}
base.OnPreRender(e);
}
}