document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1.     protected void TextBox1_Init(object sender, EventArgs e)
  2.     {  
  3.         // get the text box
  4.         TextBox tb=(sender as TextBox);
  5.  
  6.         // read the ASP tooltip as the watermark text
  7.         string defaulttext = tb.ToolTip;
  8.  
  9.         // if the field is blank, set text to the tooltip
  10.         // this only fires of on init of the page, not as
  11.         // the user is navigating around on it.
  12.         if (tb.Text == "") { tb.Text = tb.ToolTip; }
  13.  
  14.         // hook up the JavaScript events to the screen objects.
  15.         tb.Attributes.Add("onFocus", "doClear(this)");
  16.         tb.Attributes.Add("onBlur", "doBlur(this)");
  17.  
  18.         //init the screen objects (only on init)
  19.         if (tb.Text == "")
  20.         {
  21.             tb.CssClass = "watermarked";
  22.             tb.Text = tb.ToolTip;
  23.         }
  24.         else
  25.         {
  26.             TextBox1.CssClass = "unwatermarked";
  27.         }
  28.     }
');