Ajax 水印文本框
水印文本框在普通文本框中添加水印文字效果
当文本框为空的时候该控件可以使用自定义的CSS样式给用户显示某些信息。用户输入到文本框后不再显示水印文字。通常用于告诉用户文本框的一些信息而不用页面的其他地方。
TextBoxWatermark is an ASP.NET AJAX extender that can be attached to an ASP.NET TextBox control to get "watermark" behavior. When a watermarked TextBox is empty, it displays a message to the user with a custom CSS style. Once the user has typed some text into the TextBox, the watermarked appearance goes away. The typical purpose of a watermark is to provide more information to the user about the TextBox itself without cluttering up the rest of the page.
控件的属性
The control above is initialized with this code. The italic properties are optional:
<ajaxToolkit:TextBoxWatermarkExtender ID="TBWE2" runat="server" TargetControlID="TextBox1" WatermarkText="Type First Name Here" WatermarkCssClass="watermarked" />
- TargetControlID - The ID of the TextBox to operate on 目标控件id
- WatermarkText - The text to show when the control has no value 目标控件为空时显示的水印文字
- WatermarkCssClass - The CSS class to apply to the TextBox when it has no value (e.g. the watermark text is shown). 目标文本框为空时水印文字使用的CSS样式,如上图