[ToolboxData("<{0}:TextBox runat=server></{0}:TextBox>")]
public class TextBox : System.Web.UI.WebControls.TextBox
{
[Bindable(true)]
[Category("Appearance")]
[DefaultValue("")]
[Localizable(true)]
[Browsable(true)]
public string Tip
{
get
{
String s = (String)ViewState["Tip"];
return ((s == null) ? String.Empty : s);
}
{
ViewState["Tip"] = value;
}
}
[Category("Appearance")]
[DefaultValue("")]
[Localizable(true)]
public override string Text
{
get
{
if (base.Text.ToLower() == Tip.ToLower())
return string.Empty;
return base.Text;
}
set
{
base.Text = value;
}
}
{
this.Attributes.Add("tip",Tip);
this.Attributes.Add("onblur",
"if(this.value==''){this.style.color='#C1C1C1';this.value='"+Tip+"';};");
this.Attributes.Add("onfocus",
"if(this.value=='"+Tip+"'){this.style.color='#000000';this.value='';};");
if (string.IsNullOrEmpty(base.Text.Trim()))
{
this.Attributes.Add("value", this.Tip);
this.Attributes.Add("style", "color:#C1C1C1");
}
}
}