Document directory
- Introduction
- Important attributes
- Example
Introduction
The textboxwatermark control is a watermark control used for textbox. Before entering text in the text box, there are some prompt text in the text box, and you can customize CSS to control its style, I don't think it is very useful, but it brings convenience to users and good visual effects.
Important attributes
Targetcontrolid: ID of the text box to apply the watermark Effect
Watermarktext: the prompt Text of the watermark effect.
Watermarkcssclass: CSS style used for watermark Effect
Example
1. Open vs2005 and create an ajaxcontroltoolkit website named oec2003_textboxwatermark.
2. Open the default. aspx page and switch to the design view.
3. Add two text boxes and two textboxwatermark controls, as shown in figure
4. Switch to the Code view and set the attributes of the textboxwatermark control. The Code is as follows:
<Ajaxtoolkit: textboxwatermarkextender id = "textboxwatermarkextender1" runat = "server" targetcontrolid = "textbox2" watermarktext = "Enter the user name" watermarkcssclass = "water1"> </ajaxtoolkit: authorization> <ajaxtoolkit: textboxwatermarkextender id = "Courier" runat = "server" watermarktext = "enter the password" targetcontrolid = "textbox1" Highlight = "water2"> </ajaxtoolkit: textboxwatermarkextender>
5. Add the following CSS:
<style type="text/css"> .water1 { height:20px; width:150px; padding:2px 0 0 2px; border:1px solid #BEBEBE; background-color:#F0F8FF; color:red;}.water2{ height:20px; width:150px; border:1px none #ffffcc; background-color:#ccccff; color:green;}</style>
Here is just a simple bit of CSS. You can also use CSS to write beautiful watermarks.
Save the design and run the program to see the effect. When you click the text box, the watermark disappears, the cursor appears in the text box, And the watermark appears again after the mouse leaves.