code.Atomic8Ball.com

Textbox Watermark Instructions

This control uses the Asp.net Ajax Control Toolkit, it's a bit of a pain to set up, but after that the controls are easy to implement.

Setting up the AjaxControlToolkit

  1. Create a new folder in the root directory of your website called bin and (Right Click, Save Link As..) AjaxControlToolkit.dll to that directory.
  2. Add the following to your MasterPage.master just below the opening <form> tag. <asp:ScriptManager runat="server" ID="smACT" />
    Note: Test here, if your site is not working locally and giving you the error "Unknown server tag 'asp:ScriptManager'", you'll need to make some modifications to your Web.config file. Check the Web.config of a site that is working with AjaxControlToolkit (this one, for example) and use the contents of the file, do not overwrite the appSettings and connectingStrings sections in your own file, they are important.
  3. Add <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %> to the page or user control you would like to use the AjaxControlToolkit. From here you will be able to utilize all the controls listed on http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite

Using AjaxControlToolkit Textbox Watermark Extender

  1. Add an asp:TextBox that you would like to Watermark to your page, make sure it has runat="server" and a unique ID <asp:TextBox runat="server" ID="txtSample" />
  2. Add <ajaxToolkit:TextBoxWatermarkExtender runat="server" ID="tbwSample" TargetControlID="txtSample" WatermarkText="Name" WatermarkCssClass="wmark" /> anywhere on the page.
    • TargetControlID: The unique ID of your asp:TextBox
    • WatermarkText: The text that will show in the TextBox
    • WatermarkCssClass: If you would like you can apply a class to your watermarks to make them appear faded or have different coloring than actual text.